You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Derek Hohls <dh...@csir.co.za> on 2005/07/13 16:13:50 UTC

[SOLVED] Re: Mysql connection error

Quick follow-up.

I check with the admin staff and the mysql client had been
installed and so was able to test the permissions as per 
your guidelines - that worked and I was also able to  run 
my  query OK.

So I figured there must be a problem with the Cocoon
setup... somewhere.  I went back to that "old" IBM
tutorial [really needs updating!] and found this in the
install section:

"check that the driver has been properly installed and loaded.
Restart Tomcat to ensure that all classes are properly reloaded. 
Once Tomcat and Cocoon 2 have restarted, check the 
$COCOON_HOME/WEB-INF/logs/access.log
file for an entry similar to the following:
(Unknown-URI) Unknown-thread/CocoonServlet:
Trying to load class: org.hsqldb.jdbcDriver
This indicates that the server is attempting to load the driver. 
If a java.lang.ClassNotFoundException has been logged after 
this message, then the driver is not correctly installed."

I did and sure enough - there was the ClassNotFoundException !

On double-checking I found the mysql driver file was not in
the lib directory... I think that between my starting on this
problem (yesterday) and these latest tests, the version of 
Ccooon had been upgraded - and the "extra" jar was not
reinstalled - what a waste of a day!

Thanks again, though, for the patient support. I continue to learn;
albeit at a painful pace.

Signing off
Derek


>>> dhohls@csir.co.za 2005/07/13 03:42:36 PM >>>
Upayavira

This makes sense, except for the "mysql client" part.

My MachineB is the equivalent of your Windows (except 
it runs Linux, but I assume that makes no difference); 
and my MachineA  is the equivalent of your chandra (and
also running mysql).

The only difference is that there is not a "mysql client"
running on MachineB - I am not the admin for this machine
and am not sure I can get a "mysql client" installed on it.
Is there any simple way to test the connection as you have 
done?

AFAIK I have created the permissions for the user on the 
remote machine to  access your database - as per Step 5
in my post below.  (This is always the way I have done
it before but I have a nagging feeling there is now some 
subtle difference somewhere in the new setup..)

Thanks
Derek



>>> uv@odoko.co.uk 2005/07/13 03:16:05 PM >>>
I have Mysql running on Linux, on host Chandra.

I have the mysql client running on windows, host creatively named win2k.

If I log onto win2k and run:

mysql -uroot -ppasswd -h chandra

I get: Access denied for user: 'root@192.168.1.100' (Using password: YES)

So, I logged onto chandra and did:

grant all privileges on *.* to root@192.168.1.100 idenitifed by 'passwd';

Then I repeated the command from win2k, and it let me in to chandra.

Hope that makes sense.

So, have you set permissions for the user on the remote machine to 
access your database?

Regards, Upayavira


Derek Hohls wrote:
> Uh - if I try:
> 
> ./mysql -u myname -ppasswd -h machineB.com
> 
> that gives me the error:
> 
> Access denied for user "machineA.com" 
> (machine A is where I have telnetted into [from MachineB]
> ... and is also where the database is located - this is in line 
> with the manual which states:
> 
> "If mysql -u root test works but mysql -h your_hostname -u root 
> results in Access denied (where your_hostname is the 
> **actual hostname of the local host***),
> 
> But I am trying to test the connection from machineB ??
> 
> Thanks
> Derek
> 
> 
>>>>uv@odoko.co.uk 2005/07/13 02:36:21 PM >>>
> 
> Derek Hohls wrote:
> 
>>Upayavira
>>
>>Thanks for the heads-up.
>>
>>I have now tried using the machine name as well... but with no
>>success.
>>
>>Re the second approach - this is not clear to me.  I would normally
>>telnet into the box, then run ./mysql -u myname -p to work with
>>sql.  However, my understanding is that when I do this I am 
>>essentially connecting to mysql from the localhost.  How do I connect
>>from the remote machine to the database server using the mysql 
>>command as you suggest?
> 
> 
> er, ./mysql -u myname -ppasswd -h hostname
> 
> :-)
> 
> Regards, Upayavira
> 
> 
>>>>>uv@odoko.co.uk 2005/07/13 01:22:06 PM >>>
>>
>>Could be that you need to grant authorisation by machine name not by IP. 
>>I've had struggles with that sort of thing before.
>>
>>Best to debug this by trying to login to remote host just using the 
>>mysql command at the command line. Then, once you've got that working, 
>>you can scale up to doing it with Cocoon.
>>
>>Regards, Upayavira
>>
>>Derek Hohls wrote:
>>
>>
>>>I am struggling with getting a new server to communicate with a mySQL database on another machine.
>>>
>>>The database and queries work fine, when running on machine A, where the database is installed,
>>>as does the Cocoon application when running there.  
>>>
>>>However, when I try and emulate the Cocoon application on machine B 
>>>(same OS, same Cocoon version - Linux, C2.1.6),
>>>I get a null pointer exception that I cannot seem to solve.
>>>
>>>Here is what I have done.
>>>
>>>1. Copied the mysql-connector-java-3.1.7-bin.jar file to tomcat\webapps\cocoon\WEB-INF\lib\
>>>
>>>2. Added an entry in web.xml for "com.mysql.jdbc.Driver"
>>>
>>>3. Aded an entry in the cocoon.xconf for:
>>>
>>>	<jdbc name="mydb">
>>>		<pool-controller min="1" max="50"/>
>>>		<auto-commit>true</auto-commit>
>>>		<dburl>jdbc:mysql://dbserver.alias.com/mydbname</dburl>
>>>		<user>myuser</user>
>>>		<password>mypassword</password>
>>>	</jdbc>
>>>
>>>4. Restarted Cocoon
>>>
>>>5. Added a "myuser" entry to the mySQL user table on the database machine, with 
>>>
>>>USE mysql;
>>>GRANT USAGE ON *.* to myuser@"99.99.99.99" IDENTIFIED BY 'mypassword';
>>>GRANT SELECT ON mydbname.* to ffpreporter@"99.99.99.99";
>>>
>>>(obviously I am using the actual IP address of Machine B)
>>>
>>>6.  The pipeline in question looks like:
>>>
>>><map:match pattern="testproject">
>>>   <map:generate src="sql.xml"/>
>>>   <!-- === SQL Connector ====  -->      
>>>   <map:transform type="sql">
>>>     <map:parameter name="use-connection" value="mydb"/>
>>>     <map:parameter name="show-nr-of-rows" value="true"/> 
>>>     <map:parameter name="clob-encoding" value="UTF-8"/> 
>>>   </map:transform> 
>>>   <map:serialize type="xml"/>
>>></map:match> 	      
>>>
>>>7.  the SQL file contains:
>>>
>>><?xml version="1.0" encoding="UTF-8" ?> 
>>><sq2:execute-query xmlns:sq2="http://apache.org/cocoon/SQL/2.0">
>>><sq2:query name="themes">
>>> SELECT DISTINCT * FROM mytable
>>></sq2:query>
>>></sq2:execute-query>
>>>
>>>8.  The stacktrace from Cocoon is a java.lang.NullPointerException;
>>>looking in the error.log reveals:
>>>
>>>ERROR   (2005-07-13) 12:40.11:694   [sitemap.transformer.sql] 
>>>(/cocoon/myapp/testproject) http-8080-Processor4/SQLTransformer.Query: Caught a SQLException
>>>java.sql.SQLException: Failed to obtain connection. Made 5 attempts with 5000ms interval
>>>
>>>
>>>How do I go about trying to pin down why this is happening?
>>>
>>>Thanks
>>>Derek

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


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


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


Re: [SOLVED] Re: Mysql connection error

Posted by Upayavira <uv...@odoko.co.uk>.
Derek Hohls wrote:
> Quick follow-up.
> 
> I check with the admin staff and the mysql client had been
> installed and so was able to test the permissions as per 
> your guidelines - that worked and I was also able to  run 
> my  query OK.
> 
> So I figured there must be a problem with the Cocoon
> setup... somewhere.  I went back to that "old" IBM
> tutorial [really needs updating!] and found this in the
> install section:
> 
> "check that the driver has been properly installed and loaded.
> Restart Tomcat to ensure that all classes are properly reloaded. 
> Once Tomcat and Cocoon 2 have restarted, check the 
> $COCOON_HOME/WEB-INF/logs/access.log
> file for an entry similar to the following:
> (Unknown-URI) Unknown-thread/CocoonServlet:
> Trying to load class: org.hsqldb.jdbcDriver
> This indicates that the server is attempting to load the driver. 
> If a java.lang.ClassNotFoundException has been logged after 
> this message, then the driver is not correctly installed."
> 
> I did and sure enough - there was the ClassNotFoundException !
> 
> On double-checking I found the mysql driver file was not in
> the lib directory... I think that between my starting on this
> problem (yesterday) and these latest tests, the version of 
> Ccooon had been upgraded - and the "extra" jar was not
> reinstalled - what a waste of a day!
> 
> Thanks again, though, for the patient support. I continue to learn;
> albeit at a painful pace.

Well done for fixing it.

That is the nature of these problems - they're brutally obvious, once 
you've fixed them :-)

Regards, Upayavira

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