cannot setup JNDI with MySQL
Hello 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. I never get to see the datasource registered Tomcat Administration Tool. I've included in server.xml the following lines somewhere inside the .. factory org.apache.commons.dbcp.BasicDataSourceFactory driverClassName com.mysql.jdbc.Driver url jdbc:mysql://localhost:3306/dea?autoReconnect=true username myusername password mypassword maxActive 20 maxIdle 10 maxWait 40 I have Tomcat/5.0.28 And the following files in common\lib mysql-connector-java-3.1.10-bin.jar commons-collections-3.1.jar commons-dbcp-1.2.1.jar commons-pool-1.2.jar * *What I get in tomcat\logs\stdout.log is: NotifyUtil::java.net.ConnectException: Connection refused: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:295) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:161) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:148) at java.net.Socket.connect(Socket.java:425) at java.net.Socket.connect(Socket.java:375) at sun.net.NetworkClient.doConnect(NetworkClient.java:139) at sun.net.www.http.HttpClient.openServer(HttpClient.java:366) at sun.net.www.http.HttpClient.openServer(HttpClient.java:582) at sun.net.www.http.HttpClient.(HttpClient.java:292) at sun.net.www.http.HttpClient.(HttpClient.java:253) at sun.net.www.http.HttpClient.New(HttpClient.java:321) at sun.net.www.http.HttpClient.New(HttpClient.java:306) at sun.net.www.http.HttpClient.New(HttpClient.java:301) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:469) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:460) at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:516) at org.netbeans.modules.web.monitor.server.NotifyUtil$RecordSender.run(NotifyUtil.java:237) What did I miss? I've even tried setting up the JNDI in the conf\Catalina\localhost\myapp.xml And also tried instead of I also tried all that with the org.gjt.mm.mysql.Driver Regards, I. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: cannot setup JNDI with MySQL
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: url jdbc:mysql://localhost:3306/dea?autoReconnect=true password john maxActive 4 maxWait 5000 driverClassName com.mysql.jdbc.Driver maxIdle 2 username john somewhere in the 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 || tag of the examples context and the || tag closing the localhost definition." Which I cannot understand where exctly it means. I was always trying to place it somewhere inside the 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]