I have a problem using Hibernate with c3p0 connection pool. See configuration and exceptions below.
Well, moreover I wondered what happens, if hibernate.c3p0.max_size is greater than mysql concurrent users? Can this lead to exceptions as well?
This is related to a common problem mentioned on dev.mysql.com:
Quote:
1.5.1.4:
I have a servlet/application that works fine for a day, and then stops working overnight
http://dev.mysql.com/doc/connector/j/en/cj-faq.html
Hibernate version:
3.1 beta 1
Database:
MySQL 4.1.14
JDBC Driver:
MySQL Connector/J 3.1.10
Connection Pool:
c3p0 v. 0.9.0 (delivered with Hibernate 3.1)
hibernate.properties:
hibernate.connection.url jdbc:mysql://localhost/mydb?autoReconnect=true
hibernate.c3p0.max_size 75
hibernate.c3p0.min_size 3
hibernate.c3p0.timeout 3600
hibernate.c3p0.max_statements 0
hibernate.c3p0.idle_test_period 1800
hibernate.c3p0.acquire_increment 2
hibernate.c3p0.validate false
c3p0.properties:
c3p0.initialPoolSize=3
c3p0.autoCommitOnClose=false
c3p0.forceIgnoreUnresolvedTransactions=false
c3p0.idleConnectionTestPeriod=1800
c3p0.testConnectionOnCheckin=true
c3p0.testConnectionOnCheckout=true
c3p0.automaticTestTable=c3p0_test_table
com.mchange.v2.log.MLog=com.mchange.v2.log.log4j.Log4jMLog
Exception:
Code:
javax.servlet.ServletException: could not execute query
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
org.hibernate.exception.GenericJDBCException: could not execute query
org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92)
org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:80)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.loader.Loader.doList(Loader.java:1962)
org.hibernate.loader.Loader.list(Loader.java:1943)
org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:405)
org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:293)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:862)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
de.w3s.webapp.struts.actions.admin.SelectSurveyStatesAction.execute(SelectSurveyStatesAction.java:83)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Code:
WARN 01.09.2005 00:51:14,665 com.mchange.v2.c3p0.impl.NewPooledConnection (NewPooledConnection:handleThrowable:356) - [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
WARN 01.09.2005 00:51:14,666 com.mchange.v2.c3p0.impl.NewPooledConnection (NewPooledConnection:handleThrowable:357) - [c3p0] Another error has occurred [ com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
Last packet sent to the server was 2 ms ago.
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2707)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2618)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1551)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2978)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:930)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1024)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1618)
at org.hibernate.loader.Loader.doQuery(Loader.java:639)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:221)
at org.hibernate.loader.Loader.doList(Loader.java:1959)
... 27 more
WARN 01.09.2005 00:51:14,665 com.mchange.v2.c3p0.impl.NewPooledConnection (NewPooledConnection:handleThrowable:356) - [c3p0] A PooledConnection that has already signalled a Connection error is still in use!
WARN 01.09.2005 00:51:14,666 com.mchange.v2.c3p0.impl.NewPooledConnection (NewPooledConnection:handleThrowable:357) - [c3p0] Another error has occurred [ com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: Broken pipe
STACKTRACE:
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2689)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2618)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1551)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2978)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2902)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:930)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1024)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1618)
at org.hibernate.loader.Loader.doQuery(Loader.java:639)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:221)
at org.hibernate.loader.Loader.doList(Loader.java:1959)
at org.hibernate.loader.Loader.list(Loader.java:1943)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:405)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:293)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:862)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at de.w3s.webapp.struts.actions.admin.SelectSurveyStatesAction.execute(SelectSurveyStatesAction.java:83)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:407)
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:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
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 **
Thanks for your help!
Best regards
Sven