You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Omar Adobati <om...@gmail.com> on 2005/11/08 23:19:13 UTC
ESQL PRoblems
Good Morning to all,
I'm having some problems in using ESQL... really I can't yet use it...
I'm trying to use mySQL database on cocoon 2.1.7 running under Tomcat
5.5.9 on a Windows XP machine...
I'have done all the steps I need (maybe I think):
1) I have putted the connector-j to the $COCOON$/WEB-INF/lib directory
2) added to the $COCOON$/WEB-INF/cocoon.xconfig the following code
<datasources>
<jdbc name="test_mysql_pool">
<pool-controller min="5" max="10"/>
<auto-commit>true</auto-commit>
<dburl>jdbc:mysql://localhost:3306/prova</dburl>
<user>root</user>
<password></password>
</jdbc>
</datasources>
Yes, my DB is called prova and has no password (it's just a test db)
3) Added to $COCOON$/WEB-INF/web.xml the following code:
<init-param>
<param-name>load-class</param-name>
<param-value>
com.mysql.jdbc.Driver
</param-value>
</init-param>
then I have written a XSP page with the following code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsp:page language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:esql="http://apache.org/cocoon/SQL/v2"
>
<esql:connection>
<esql:pool>test_mysql_pool</esql:pool>
<esql:execute-query>
<esql:query>SELECT * FROM test</esql:query>
<esql:results>
<table>
<esql:row-results>
<tr>
<td><esql:get-string column="cognome"/></td>
<td><esql:get-string column="nome"/></td>
</tr>
</esql:row-results>
</table>
</esql:results>
<esql:error-results>
Error:<br/>
<esql:get-message/>
<esql:to-string/>
<esql:get-stacktrace/>
</esql:error-results>
<esql:no-results>
<p>Sorry, no results!</p>
</esql:no-results>
</esql:execute-query>
</esql:connection>
</xsp:page>
Now, my question is: There is any mistake in my configuration? Why I
cant' have back any message also if I'm using the tags between
<esql:error-results>??
I hope to be clear, if not, please ask me for what's not understandable!
Thanks in advice,
Omar
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: ESQL PRoblems
Posted by Omar Adobati <om...@gmail.com>.
> Second possiblity: esql:connection can't be top element after
> xsp:page and this is the reason of Your problem.
This was the matter, now I have fixed it and also the sitemap.xmap
'cause I wan not set my page as a dynamic-page... this is what I done:
<map:match pattern="DBTest.xsp">
<map:call resource="dynamic-page">
<map:parameter name="target" value="DBTest"/>
<map:parameter name="remove" value="{0}"/>
</map:call>
</map:match>
Now I have a new question:
what are the means of <map:parameter name="remove" value="{0}"/>? I
know what is the mean of the {0} but why remove? what will be removed?
thanks to all,
Omar
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: ESQL PRoblems
Posted by Grzegorz TaƱczyk <go...@polzone.pl>.
Hello Omar,
Try test JDBC connection this way:
<xsp:structure>
<xsp:include>org.apache.avalon.excalibur.datasource.DataSourceComponent</xsp:include>
</xsp:structure>
...
<xsp:logic><![CDATA[
try {
ComponentSelector selector = (ComponentSelector) manager.lookup(DataSourceComponent.ROLE + "Selector");
DataSourceComponent datasource = (DataSourceComponent) selector.select("test_mysql_pool");
Connection connection = datasource.getConnection();
PreparedStatement stmt = connection.prepareStatement("SELECT * FROM test");
stmt.execute();
if(stmt.getResultSet().next())
System.out.println("ok");
else
System.out.println("no results");
catch(Exception e) {
System.out.println("error: " + e.getMessage());
}
]]></xsp:logic>
and check catalina.out :)
Second possiblity: esql:connection can't be top element after
xsp:page and this is the reason of Your problem.
Tuesday, November 8, 2005, 11:19:13 PM, you wrote:
OA> Good Morning to all,
OA> I'm having some problems in using ESQL... really I can't yet use it...
OA> I'm trying to use mySQL database on cocoon 2.1.7 running under Tomcat
OA> 5.5.9 on a Windows XP machine...
OA> I'have done all the steps I need (maybe I think):
OA> 1) I have putted the connector-j to the $COCOON$/WEB-INF/lib directory
OA> 2) added to the $COCOON$/WEB-INF/cocoon.xconfig the following code
OA> <datasources>
OA> <jdbc name="test_mysql_pool">
OA> <pool-controller min="5" max="10"/>
OA> <auto-commit>true</auto-commit>
OA> <dburl>jdbc:mysql://localhost:3306/prova</dburl>
OA> <user>root</user>
OA> <password></password>
OA> </jdbc>
OA> </datasources>
OA> Yes, my DB is called prova and has no password (it's just a test db)
OA> 3) Added to $COCOON$/WEB-INF/web.xml the following code:
OA> <init-param>
OA> <param-name>load-class</param-name>
OA> <param-value>
OA> com.mysql.jdbc.Driver
OA> </param-value>
OA> </init-param>
OA> then I have written a XSP page with the following code:
OA> <?xml version="1.0" encoding="ISO-8859-1"?>
OA> <xsp:page language="java"
OA> xmlns:xsp="http://apache.org/xsp"
OA> xmlns:esql="http://apache.org/cocoon/SQL/v2"
>>
OA> <esql:connection>
OA> <esql:pool>test_mysql_pool</esql:pool>
OA> <esql:execute-query>
OA> <esql:query>SELECT * FROM test</esql:query>
OA> <esql:results>
OA> <table>
OA> <esql:row-results>
OA> <tr>
OA> <td><esql:get-string column="cognome"/></td>
OA> <td><esql:get-string column="nome"/></td>
OA> </tr>
OA> </esql:row-results>
OA> </table>
OA> </esql:results>
OA> <esql:error-results>
OA> Error:<br/>
OA> <esql:get-message/>
OA> <esql:to-string/>
OA> <esql:get-stacktrace/>
OA> </esql:error-results>
OA> <esql:no-results>
OA> <p>Sorry, no results!</p>
OA> </esql:no-results>
OA> </esql:execute-query>
OA> </esql:connection>
OA> </xsp:page>
OA> Now, my question is: There is any mistake in my configuration? Why I
OA> cant' have back any message also if I'm using the tags between
OA> <esql:error-results>??
OA> I hope to be clear, if not, please ask me for what's not understandable!
OA> Thanks in advice,
OA> Omar
OA> ---------------------------------------------------------------------
OA> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
OA> For additional commands, e-mail: users-help@cocoon.apache.org
--
Best regards,
Grzegorz mailto:goliatus@polzone.pl
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org