<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT color=#000080 face=Arial size=2>Hello,</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#000080 face=Arial size=2> Connceted MySQL in
OpenCms well.</FONT></DIV>
<DIV><FONT color=#000080 face=Arial size=2> My JDBC - MySQL
connectivity works well but small problem arise...</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#000080 face=Arial size=2> When I fetched the data
from table (here "test").....</FONT></DIV>
<DIV><FONT color=#000080 face=Arial size=2> Definite I found the
dataset(records) but I also found</FONT><FONT color=#000080 face=Arial
size=2> in the front of template "null".</FONT></DIV>
<DIV><FONT color=#000080 face=Arial size=2> I don't guess
it!</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#000080 face=Arial size=2> I fetched the dataset in
template via Object, m</FONT><FONT color=#000080 face=Arial size=2>y sample java
code is here.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#000080><FONT face=Arial
size=2> //////// javacode //////////////////
</FONT></DIV>
<P class=MsoPlainText><FONT face=Arial size=2><SPAN
style="mso-fareast-font-family: 'MS Mincho'">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><SPAN
style="mso-tab-count: 1"> </SPAN>public Object
getDataset1(CmsObject cms, String tagcontent, <BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>A_CmsXmlContent doc, Object userObject)<BR><SPAN
style="mso-spacerun: yes"> </SPAN><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>throws CmsException {<BR><SPAN
style="mso-tab-count: 2">
</SPAN><BR><BR><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>Connection con1 = null;<BR><SPAN
style="mso-tab-count: 1"> </SPAN><SPAN
style="mso-tab-count: 1"> </SPAN>PreparedStatement
statement1 = null;<BR><SPAN
style="mso-tab-count: 1"> </SPAN><SPAN
style="mso-tab-count: 1"> </SPAN>ResultSet res1 =
null;<BR><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>String poolname1 = "jdbc:opencmspool:mysql";<BR><SPAN
style="mso-tab-count: 1"> </SPAN><SPAN
style="mso-tab-count: 1"> </SPAN>String ret1 =
null;<BR><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>String f2,f3,f4 = null;<BR><SPAN
style="mso-tab-count: 1"> </SPAN><SPAN
style="mso-tab-count: 1"> </SPAN>String row1 =
null;<BR><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>final String SELECT = "select * from test";<BR><BR><SPAN
style="mso-tab-count: 1"> </SPAN><SPAN
style="mso-tab-count: 1">
</SPAN>CmsXmlTemplateFile template1 = (CmsXmlTemplateFile)doc;<BR><BR><SPAN
style="mso-tab-count: 1"> </SPAN><SPAN
style="mso-tab-count: 1"> </SPAN>try {<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>con1
= DriverManager.getConnection(poolname1);<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>statement1 = con1.prepareStatement(SELECT);<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>res1
= statement1.executeQuery();<BR><SPAN
style="mso-tab-count: 1"> </SPAN><BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>while(res1.next()){<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>//
read the items from the resultset<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>f2 =
res1.getString(1);<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>f3 =
res1.getString(2);<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>f4 =
res1.getString(3);<BR><BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>template1.setData("name", f2);<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>template1.setData("email", f3);<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>template1.setData("phone", f4);<BR><BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>row1
= template1.getProcessedDataValue("row1");<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>ret1= ret1 + row1;<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>}<BR><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>}catch(SQLException e) {<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>//
exception-handling<BR><SPAN
style="mso-tab-count: 1"> </SPAN><SPAN
style="mso-tab-count: 1">
</SPAN>}finally{<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>try{<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>res1.close();<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>}catch (Exception exc) {<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>//
ignore this exception<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>}<BR><SPAN style="mso-tab-count: 1">
</SPAN><BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>try{<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>statement1.close();<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>}
catch(Exception exc) {<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>//
ignore the exception<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>}<BR><SPAN style="mso-tab-count: 1">
</SPAN><BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>try{<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>con1.close();<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>}
catch(Exception exc) {<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>//
ignore the exception<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-tab-count: 1">
</SPAN>}<BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-spacerun: yes"> </SPAN>}<BR><BR><SPAN
style="mso-tab-count: 2">
</SPAN><SPAN style="mso-spacerun: yes"> </SPAN>return ret1;<BR><SPAN
style="mso-spacerun: yes"> </SPAN><SPAN
style="mso-tab-count: 1">
</SPAN>}<BR><BR><BR>}<BR><BR> ///////////// End javacode
////////////////////////</SPAN></FONT></P>
<P class=MsoPlainText><FONT face=Arial size=2><SPAN
style="mso-fareast-font-family: 'MS Mincho'">I have already "test" table with
three fields : 1) name 2) email 3) phone (All are
String).</SPAN></FONT></P><SPAN style="mso-fareast-font-family: 'MS Mincho'">
<P class=MsoPlainText><FONT face=Arial size=2><SPAN
style="mso-fareast-font-family: 'MS Mincho'">Please give me ideas that when
I go wrong!.... Advanced thanks....</SPAN></FONT></P>
<P class=MsoPlainText><FONT face=Arial size=2><STRONG></STRONG></FONT> </P>
<P class=MsoPlainText><FONT face=Arial size=2><STRONG>M.
Solanki.</STRONG></FONT></SPAN></FONT></P></BODY></HTML>