You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Guy Picton Phillipps <gu...@brentpct.nhs.uk> on 2004/06/18 19:39:41 UTC

Problem connecting to MySQL

Dear Listers,
I am a newbie with Apache Cocoon and am trying my hand connecting to a MySQL
database, with some difficulty. I have researched alot and still cannot find
the answer to this problem. 

First the background info: 

Cocoon 2.1.5
Tomcat 5.0.27
mysql-3.23.38
j2sdk1.4.2_04
mysql-connector-java-3.0.11-stable-bin.jar

I have adjusted the following files to setup a database connection to MySQL:

***********cocoon.xconf**********
 <datasources>
  		<jdbc name="ward_connect">
  			<pool-controller min="5" max="10"/>
 
<dburl>jdbc:mysql://localhost:3306/ward_data?autoReconnect=true</dburl>
  			<user>myusername</user>
  			<password>mypassword</password>
  		</jdbc>
 </datasources>



************web.xml****************
<init-param>
	<param-name>load-class</param-name>
	<param-value>
		<!--For SQL Database Driver-->
        		com.mysql.jdbc.Driver
	</param-value>
</init-param>



*********sitemap.xmap****************

	<map:pipelines>
		<map:pipeline>
			<map:match pattern="sqlconnect">
				<map:generate src="sqlextract.xml"/>
				<map:transform type="sql">
					<map:parameter name="use-connection"
value="ward_connect"/>
				</map:transform>
				<map:serialize type="xml"/>
			</map:match>
		</map:pipeline>
	</map:pipelines>


......and am using this xml file to describe the SQL query and also to
describe the connection parameters again:

**********sqlextract.xml***************

<?xml version="1.0" encoding="UTF-8"?>
<document>
	<sql:execute-query xmlns:sql="http://apache.org/cocoon/sql/2.0">
		<sql:use-connection>ward_connect</sql:use-connection>
		<sql:query>
			select admin_name from wards;
		</sql:query>
	</sql:execute-query>
</document>


I have copied the mysql-connector-java-3.0.11-stable-bin.jar file to the
C:\jakarta-tomcat-5.0.27\common\lib and set up the JAVA SDK as per
instructions

BUT when I try and view http://localhost:8080/cocoon-test/sqlconnect in my
browser, all I get is an xml replication of the sqlextract.xml document and
when I check the Access Log file, there is a message as per the following:

**************************************************************************
INFO    (2004-06-18) 18:14.38:062   [access] (Unknown-URI)
Unknown-thread/CocoonServlet: Reloading from:
jndi:/localhost/cocoon-test/WEB-INF/cocoon.xconf
INFO    (2004-06-18) 18:15.45:500   [access] (/cocoon-test/sqlconnect)
http-8080-Processor25/CocoonServlet: 'sqlconnect' Processed by Apache Cocoon
2.1.5 in 1.969 seconds.
**************************************************************************

The output is not what I was expecting, which should be a list of names - is
there a problem with the way I have set up the database connection? Do I
need to add a different serializer to view the output? I was under the
impression that the XML serializer would deliver the raw SQL data to the
browser. The SQL Query "select admin_name from wards" works from the MySQL
prompt. 

Any help will be greatly appreciated as I have no idea why this is
happening.....

cheers,

Guy






**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

Kensington & Chelsea PCT
**********************************************************************


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Problem connecting to MySQL

Posted by Tony Collen <co...@umn.edu>.
Tony Collen wrote:

> <document xmlns:sql="xmlns:sql="http://apache.org/cocoon/sql/2.0">
> 
> and then just use:
> 
> <sql:execute-query>
>   <sql:use-connection>ward_connect</sql:use-connection>
>   <sql:query>select admin_name from wards;</sql:query>
> </sql:execute-query>


Whoops, wow, my mail client *really* likes to mangle namespace declarations.  Ignore the literal 
text, and just try declaring the sql namespace in the root <document> tag, and see if it works.

Tony


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Problem connecting to MySQL

Posted by Tony Collen <co...@umn.edu>.
Guy Picton Phillipps wrote:
> Dear Listers,
> I am a newbie with Apache Cocoon and am trying my hand connecting to a MySQL
> database, with some difficulty. I have researched alot and still cannot find
> the answer to this problem. 
> 

&snip;

Hmm, everything looks kosher. It appears the SQLTransformer is not SQLTransforming :)

You said you copied the mysql jar into the tomcat lib directory... did you restart Tomcat after this?

> The output is not what I was expecting, which should be a list of names - is
> there a problem with the way I have set up the database connection? 

Nope, this looks OK.

> Do I
> need to add a different serializer to view the output? I was under the
> impression that the XML serializer would deliver the raw SQL data to the
> browser. 

Nope, the XML serializer is OK.

The SQL Query "select admin_name from wards" works from the MySQL
> prompt. 
> 
> Any help will be greatly appreciated as I have no idea why this is
> happening.....

Hmm, if the SQLTransformer is not transforming, I would think that it has something to do with your 
namespaces in the source document.

What if you try declaring the SQL namespace at the root tag:

<document xmlns:sql="xmlns:sql="http://apache.org/cocoon/sql/2.0">

and then just use:

<sql:execute-query>
   <sql:use-connection>ward_connect</sql:use-connection>
   <sql:query>select admin_name from wards;</sql:query>
</sql:execute-query>


Regards,

Tony


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org