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.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.connect(StandardSocketFactory.java:156)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:276)
at
com.mysql.jdbc.Connection.createNewIO(Connection.java:2815)
at
com.mysql.jdbc.Connection.<init>(Connection.java:1531)
at
com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at
org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37)
at
org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)
at
org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:877)
at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851)
at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
at
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(Unknown
Source)
at
org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(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.service(HttpJspBase.java:97)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
at
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
** END NESTED EXCEPTION **
Attempted reconnect 3 times. Giving up.)"
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:512)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(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@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]