<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">


<meta name=Generator content="Microsoft Word 10 (filtered)">

<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@MS Mincho";
        panose-1:2 2 6 9 4 2 5 8 3 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {margin-right:0in;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle19
        {font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body bgcolor=white lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>You initialized ret1 to null (ret1=null;)
and within the loop you do ret1 = ret1 + row1.  First time throught ret1 is
null.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>Initialize ret1 = “”;</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>-Rich.</span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'> </span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=2 face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma'>-----Original Message-----<br>
<b><span style='font-weight:bold'>From:</span></b>
owner-opencms-dev@www.opencms.org [mailto:owner-opencms-dev@www.opencms.org] <b><span
style='font-weight:bold'>On Behalf Of </span></b>Mayur Solanki<br>
<b><span style='font-weight:bold'>Sent:</span></b> Saturday, October 19, 2002
5:45 AM<br>
<b><span style='font-weight:bold'>To:</span></b> opencms-dev@www.opencms.org<br>
<b><span style='font-weight:bold'>Subject:</span></b> [opencms-dev] null?</span></font></p>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> </span></font></p>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>Hello,</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> </span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>   Connceted
MySQL in OpenCms well.</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>   My JDBC
- MySQL connectivity works well but small problem arise...</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> </span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>   When I
fetched the data from table (here "test").....</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>   Definite I
found the dataset(records) but I also found in the front of template
"null".</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>   I don't
guess it!</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> </span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'>   I fetched
the dataset in template via Object, my sample java code is here.</span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'> </span></font></p>

</div>

<div>

<p class=MsoNormal style='margin-left:.5in'><font size=2 color=navy face=Arial><span
style='font-size:10.0pt;font-family:Arial;color:navy'> ////////   
javacode //////////////////  </span></font></p>

</div>

<p class=MsoPlainText style='margin-left:.5in'><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>import
com.opencms.file.*;<br>
import com.opencms.core.*;<br>
import com.opencms.template.*;<br>
import com.opencms.defaults.*;<br>
import com.opencms.file.mySql.*;<br>
<br>
import java.sql.*;<br>
import java.lang.*;<br>
import java.util.*;<br>
<br>
public class con extends CmsXmlTemplate<br>
{<br>
<br>
            public Object getDataset1(CmsObject cms, String tagcontent, <br>
                                    A_CmsXmlContent doc, Object userObject)<br>
                                                throws CmsException {<br>
                        <br>
<br>
                        Connection con1 = null;<br>
                        PreparedStatement statement1 = null;<br>
                        ResultSet res1 = null;<br>
                        String poolname1 = "jdbc:opencmspool:mysql";<br>
                        String ret1 = null;<br>
                        String f2,f3,f4 = null;<br>
                        String row1 = null;<br>
                        final String SELECT = "select * from test";<br>
<br>
                        CmsXmlTemplateFile template1 = (CmsXmlTemplateFile)doc;<br>
<br>
                        try {<br>
                                    con1 =
DriverManager.getConnection(poolname1);<br>
                                    statement1 = con1.prepareStatement(SELECT);<br>
                                    res1 = statement1.executeQuery();<br>
            <br>
                                    while(res1.next()){<br>
                                                // read the items from the
resultset<br>
                                                f2 = res1.getString(1);<br>
                                                f3 = res1.getString(2);<br>
                                                f4 = res1.getString(3);<br>
<br>
                                                template1.setData("name",
f2);<br>
                                                template1.setData("email",
f3);<br>
                                                template1.setData("phone",
f4);<br>
<br>
                                                row1 =
template1.getProcessedDataValue("row1");<br>
                                                ret1= ret1 + row1;<br>
                                    }<br>
                        }catch(SQLException e) {<br>
                                    // exception-handling<br>
                        }finally{<br>
                                    try{<br>
                                                res1.close();<br>
                                    }catch (Exception exc) {<br>
                                                // ignore this exception<br>
                                    }<br>
            <br>
                                    try{<br>
                                                statement1.close();<br>
                                    } catch(Exception exc) {<br>
                                                // ignore the exception<br>
                                    }<br>
            <br>
                                    try{<br>
                                                con1.close();<br>
                                    } catch(Exception exc) {<br>
                                                // ignore the exception<br>
                                    }<br>
                          }<br>
<br>
                          return ret1;<br>
            }<br>
<br>
<br>
}<br>
<br>
 /////////////   End javacode  ////////////////////////</span></font></p>

<p class=MsoPlainText style='margin-left:.5in'><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>I have
already "test" table with three fields :  1) name  2)
email  3) phone (All are String).</span></font></p>

<p class=MsoPlainText style='margin-left:.5in'><font size=2 color=navy
face=Arial><span style='font-size:10.0pt;font-family:Arial;color:navy'>Please
give me ideas that when I go wrong!.... Advanced thanks....</span></font></p>

<p class=MsoPlainText style='margin-left:.5in'><font size=3 color=navy
face="Times New Roman"><span style='font-size:12.0pt;color:navy'> </span></font></p>

<p class=MsoPlainText style='margin-left:.5in'><strong><b><font size=2
color=navy face=Arial><span style='font-size:10.0pt;font-family:Arial;
color:navy'>M. Solanki.</span></font></b></strong></p>

</div>

</body>

</html>