Hi all.
I have a problem with connection to the database from my program. The weird part is that it is totally random. I mean that it doen't seem to be consequent. It does not happen for 2-3 days then I lost connection 2-3 times in a row then it is normal again.
I've google this for days and tried everything I found. Changing my.cnf, other polling conf, other pooling providers,... and I still got the error.
I checked that there are free available connection to the database and that timeout are not set quite high.
I'm running out of ideas. Please help.
I use c3p0 and here is what I think as relevant from my hibernate configuration file:
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/xxx?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8</property>
<property name="current_session_context_class">managed</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- configuration pool via c3p0-->
<property name="c3p0.acquire_increment">3</property>
<property name="c3p0.idle_test_period">60</property>
<property name="c3p0.initial_size">3</property>
<property name="c3p0.max_size">15</property>
<property name="c3p0.max_statements">10</property>
<property name="c3p0.min_size">3</property>
<property name="c3p0.timeout">120</property>
mySQL connector version: 5.1.5
Hibernate version: 3.2.6-ga
Code between sessionFactory.openSession() and session.close():
Product_identifier product_identifier = (Product_identifier) session.get(Product_identifier.class, product_identifier_id);
ArrayList <Upload> uploads = new ArrayList <Upload>();
Criteria criteria = session.createCriteria( Upload.class );
if (product_identifier.getProduct_fid() == 3) {
ArrayList <Long> client_id = (ArrayList <Long>) session.createQuery("SELECT client_product_identifier_fid FROM Link_manager WHERE manager_product_identifier_fid = " + product_identifier_id ).list();
if (client_id.size() > 0) {
criteria.add(Restrictions.in("product_identifier_fid", client_id));
} else {
criteria.add( Restrictions.eq( "product_identifier_fid", product_identifier_id ) );
}
}else if(product_identifier.getProduct_fid() == 2){
criteria.add(Restrictions.eq("product_identifier_fid", product_identifier_id));
}else {
criteria.add( Restrictions.eq( "product_identifier_fid", product_identifier_id ) );
}
criteria.add(Restrictions.in("uploaded", uploadedArray));
criteria.add(Restrictions.eq("removed", false));
uploads = (ArrayList <Upload>) criteria.list();
Full stack trace of any exception that occurs:
org.hibernate.exception.JDBCConnectionException: could not load an entity: [com.fileflow.hibernate.model.Product_identifier#3656]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1874)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3049)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:399)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
at com.fileflow.hibernate.DAO.UploadDAO.getUploadsForProductIdentifier(UploadDAO.java:56)
at com.fileflow.info.GetUploads.doPost(GetUploads.java:54)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Last packet sent to the server was 1 ms ago.
at sun.reflect.GeneratedConstructorAccessor54.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3134)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1818)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1961)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2543)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1737)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1888)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
... 27 more
Caused by: 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:3119)
... 37 more
Name and version of the database you are using:
MySQL 5.0.45
_________________ Best regards
Geo
|