• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mysql Connection timeout

 
Roman Merkushen
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the ORM forum.
 
Rashmi Goyal
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did setting timeout to zero worked.

thanks,
Rashmi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic