IntelliJ Java IDE
The moose likes Object Relational Mapping and the fly likes Mysql Connection timeout Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Mysql Connection timeout" Watch "Mysql Connection timeout" New topic
Author

Mysql Connection timeout

Roman Merkushen
Greenhorn

Joined: May 25, 2004
Posts: 9
Hi,
I hope you can help me. I have battling connection timeout issue with Mysql for a month now. I am using hibernate 2 with c3p0 connection pool. Hibernate config file below:

<session-factory>
<!-- properties -->
<property name="session_factory_name">jdbcSessionFactory</property>
<property name="jdbc.use_scrollable_resultset">true</property>
<property name="cglib.use_reflection_optimizer">false</property>
<property name="show_sql">false</property>
<property name="use_outer_join">true</property>
<property name="query.substitutions">true=1, false=0</property>

<!-- connection parameters -->
<property name="connection.provider_class">net.sf.hibernate.connection.C3P0ConnectionProvider</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/mydb?autoReconnect=true</property>
<property name="connection.username">username</property>
<property name="connection.password">password</property>
<property name="connection.autoReconnect">true</property>
<property name="connection.autoReconnectForPools">true</property>
<property name="connection.failOverReadOnly">true</property>
<property name="connection.is-connection-validation-required">true</property>

<!-- connection pool settings -->
<property name="c3p0.minPoolSize">5</property>
<property name="c3p0.maxPoolSize">60</property>
<property name="c3p0.timeout">600</property>
<property name="c3p0.max_statement">300</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

<!-- mapping files -->
<mapping resource="com/planet/struts/beans/or-mapping.hbm.xml"/>
<mapping resource="com/planet/struts/beans/admin/or-mapping.hbm.xml"/>
</session-factory>

After certain period of time connection timesout, then once refreshed it works fine. Any suggestions are appreciated.
Thank you.
Jeff Walker
Ranch Hand

Joined: Apr 25, 2004
Posts: 116
Roman,
I know virtually nothing about Hibernate, but you have a line in there that states:
...
<property name="c3p0.timeout">600</property>
...


Try setting it to the Hibernate default of 0 instead of 600, then it may stay up until the JVM shutsdown. I think a zero means idle connections will never expire.

Jeff Walker
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

Moving to the ORM forum.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Rashmi Goyal
Greenhorn

Joined: Sep 29, 2004
Posts: 5
did setting timeout to zero worked.

thanks,
Rashmi
 
 
subject: Mysql Connection timeout
 
Threads others viewed
Hibernate and MySQL connection issues
Connection pooling using hibernate and struts1.3
speed up the init time of hibernate
c3p0 configuration
com.mysql.jdbc.CommunicationsException MESSAGE: Communications link failure due to underlying except
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture