  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | JSP - A mailing list about Java Server Pages specification and reference | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Pooling Issue | Pooling Issue 2006-11-18 - By David Smith
Back For starters, you might want to make a copy of your server.xml file for documentation purposes and then drop all the comments from the active one. The documentation comments are excellent, but they make the serverl.xml near impossible to read.
At any rate.... the exception is connection refused. Are you sure your MySQL server is listening on port 3306? Some default configurations use unix sockets exclusively -- something java JDBC drivers can't do. Try this from the same machine your server is on:
mysql -h localhost -P 3306 -u rpd -p
The above command forces mysql client to connect via TCP/IP with userid rpd and prompt for a password. If this works, then we're looking at something else. If this doesn't, reconfigure your mysql server to listen on tcp/ip port 3306 and try again. Some additional recommendations -- not directly related to your issue, but worth mentioning:
The <Context ...> ... </Context> block should be in it's own xml file under conf/Catalina/localhost, named to match the context of your webapp -- DBTest.xml in your case. Avoid setting this in server.xml as it requires restarting the tomcat container every time you want to make a change to your webapp's config.
Drop the autoReconnect=true from your database url. It isn't recommended by MySQL and doesn't make sense in a database connection pool anyway.
--David
tyju tiui wrote: > I'm having problems setting up connection pooling with > comcat 5.5.2.0 and MySQL 5.0.24 using mysql > connector/J 5.0. > > I've setup / populated a test database and verified > that I can login to the server/db using the specified > username/password/host found in the connection string. > My server.xml looks like this: > > <snipped here .... a lot of irrelevant stuff to the issue at hand. /> > <!-- ********** Pooling Config ********** --> > <Context path="/DBTest" docBase="DBTest" > debug="5" reloadable="true" > crossContext="true"> > > > < snipped again...../> > <Resource name="jdbc/TestDB" > auth="Container" > type="javax.sql.DataSource " > > factory="org.apache.commons.dbcp.BasicDataSourceFactory " > maxActive="100" > username="rpd" > password="2wERk4rpd" > maxIdle="30" > maxWait="10000" > > driverClassName="com.mysql.jdbc.Driver " > removeAbandoned="true" > > url="jdbc:mysql://localhost:3306/phptest?autoReconnect=true" > /> > > </Context> > <!-- ********** End Pooling ********** --> > > </Host> > > </Engine> > > </Service> > > </Server> > > > > > > > > I'm using the sample web.xml and test.jsp found at: > http://tomcat.apache.org/tomcat-5 (See http://cat-5.ora-code.com).0-doc/jndi-datasource-examples-howto.html > > > > > > > There error I'm getting is: > > org.apache.jasper.JasperException : Unable to get > connection, DataSource invalid: > "org.apache.commons.dbcp.SQLNestedException : Cannot > create PoolableConnectionFactory (Server connection > failure during transaction. Due to underlying > exception: 'java.net.SocketException : > java.net.ConnectException : Connection refused'. > > ** BEGIN NESTED EXCEPTION ** > > java.net.SocketException  > MESSAGE: java.net.ConnectException : Connection refused > > STACKTRACE: > > java.net.SocketException : java.net.ConnectException : > Connection refused > at > com.mysql.jdbc.StandardSocketFactory (StandardSocketFactory.java:156) > at com.mysql.jdbc.MysqlIO <init>(MysqlIO.java:276) > at > com.mysql.jdbc.Connection (Connection.java:2815) > at > com.mysql.jdbc.Connection <init>(Connection.java:1531) > at > com.mysql.jdbc.NonRegisteringDriver (NonRegisteringDriver.java:266) > at > org.apache.commons.dbcp.DriverConnectionFactory  (DriverConnectionFactory.java:37) > at > org.apache.commons.dbcp.PoolableConnectionFactory  (PoolableConnectionFactory.java:290) > at > org.apache.commons.dbcp.BasicDataSource  (BasicDataSource.java:877) > at > org.apache.commons.dbcp.BasicDataSource (BasicDataSource.java :851) > at > org.apache.commons.dbcp.BasicDataSource (BasicDataSource.java :540) > at > org.apache.taglibs.standard.tag.common.sql.QueryTagSupport  (Unknown > Source) > at > org.apache.taglibs.standard.tag.common.sql.QueryTagSupport (Unknown > Source) > at > org.apache.jsp.test_jsp._jspx_meth_sql_query_0(test_jsp.java:100) > at > org.apache.jsp.test_jsp._jspService(test_jsp.java:58) > at > org.apache.jasper.runtime.HttpJspBase (HttpJspBase.java:97) > at > javax.servlet.http.HttpServlet (HttpServlet.java:802) > at > org.apache.jasper.servlet.JspServletWrapper (JspServletWrapper.java :334) > at > org.apache.jasper.servlet.JspServlet (JspServlet.java:314) > at > org.apache.jasper.servlet.JspServlet (JspServlet.java:264) > at > javax.servlet.http.HttpServlet (HttpServlet.java:802) > at > org.apache.catalina.core.ApplicationFilterChain  (ApplicationFilterChain.java:252) > at > org.apache.catalina.core.ApplicationFilterChain  (ApplicationFilterChain.java:173) > at > org.apache.catalina.core.StandardWrapperValve (StandardWrapperValve .java:213) > at > org.apache.catalina.core.StandardContextValve (StandardContextValve .java:178) > at > org.apache.catalina.core.StandardHostValve (StandardHostValve.java:126) > at > org.apache.catalina.valves.ErrorReportValve (ErrorReportValve.java:105) > at > org.apache.catalina.core.StandardEngineValve (StandardEngineValve.java :107) > at > org.apache.catalina.connector.CoyoteAdapter (CoyoteAdapter.java:148) > at > org.apache.coyote.http11.Http11Processor (Http11Processor.java:869) > at > org.apache.coyote.http11.Http11BaseProtocol $Http11ConnectionHandler .processConnection(Http11BaseProtocol.java:664) > at > org.apache.tomcat.util.net.PoolTcpEndpoint (PoolTcpEndpoint.java :527) > at > org.apache.tomcat.util.net.LeaderFollowerWorkerThread  (LeaderFollowerWorkerThread.java:80) > at > org.apache.tomcat.util.threads.ThreadPool $ControlRunnable.run(ThreadPool.java :684) > at java.lang.Thread (Thread.java:595) > > > ** END NESTED EXCEPTION ** > > > Attempted reconnect 3 times. Giving up.)" > > org.apache.jasper.servlet.JspServletWrapper  (JspServletWrapper.java:512) > > org.apache.jasper.servlet.JspServletWrapper (JspServletWrapper.java :377) > > org.apache.jasper.servlet.JspServlet (JspServlet.java:314) > > org.apache.jasper.servlet.JspServlet (JspServlet.java:264) > > javax.servlet.http.HttpServlet (HttpServlet.java:802) > > > > > > > > > > > Any help would be greatly appreciated. > > > > __ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ __ ____ > Sponsored Link > > Compare mortgage rates for today. > Get up to 5 free quotes. > Www2.nextag.com > > -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ > To start a new topic, e-mail: users@(protected) > To unsubscribe, e-mail: users-unsubscribe@(protected) > For additional commands, e-mail: users-help@(protected) > >
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ To start a new topic, e-mail: users@(protected) To unsubscribe, e-mail: users-unsubscribe@(protected) For additional commands, e-mail: users-help@(protected)
|
|
 |