tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Cherouvim ...@eworx.gr>
Subject Re: cannot setup JNDI with MySQL
Date Thu, 06 Oct 2005 11:38:23 GMT
Thanks for your answers.

I can connect to MySQL using any mysql tool and even with telnet 
localhost 3306 from the command line. I even tried connecting to another 
mysql server running on another pc in my LAN but nothing.

@andy: yes I have placed mysql-connector-java-3.1.10-bin.jar in 
common\lib and I also tried with different (older) versions. I've been 
leaving only one of them of course each time I tried.

I finally managed to solve the problem.
I needed to place:
    <Resource name="jdbc/TestDB" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/TestDB">
      <parameter> <name>url</name> 
<value>jdbc:mysql://localhost:3306/dea?autoReconnect=true</value> 
</parameter>
      <parameter> <name>password</name> <value>john</value>
</parameter>
      <parameter> <name>maxActive</name> <value>4</value> </parameter>
      <parameter> <name>maxWait</name> <value>5000</value> </parameter>
      <parameter> <name>driverClassName</name> 
<value>com.mysql.jdbc.Driver</value> </parameter>
      <parameter> <name>maxIdle</name> <value>2</value> </parameter>
      <parameter> <name>username</name> <value>john</value>
</parameter>
    </ResourceParams>

somewhere in the <GlobalNamingResources> element of my server.xml.
The tutorial at 
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html 
says:
"Add this in between the |</Context>| tag of the examples context and 
the |</Host>| tag closing the localhost definition."

Which I cannot understand where exctly it means. I was always trying to 
place it somewhere inside the <Host> element which was not working for me.

I solved the problem by adding the DataSource from the administration 
tool of tomcat and then I went to server.xml to see how it did it.

Regards,
J.


Hassan Schroeder wrote:

>John Cherouvim wrote:
>
>  
>
>>I've been trying to setup a mysql connection pool using JNDI as shown in
>>http://jakarta.apache.org/tomcat/tomcat-5.0-doc/jndi-datasource-examples-howto.html
>>But no luck.
>>    
>>
>
>  
>
>>*What I get in tomcat\logs\stdout.log is:
>>NotifyUtil::java.net.ConnectException: Connection refused: connect
>>   at java.net.PlainSocketImpl.socketConnect(Native Method)
>>    
>>
>
>A "Connection refused" sounds like your driver config is fine but
>either MySQL isn't running, it's configured with skip-networking,
>or you've got a firewall/iptables/whatever issue.
>
>Can you connect (`telnet localhost 3306`) from the command line?
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message