Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate and MySQL connection issues

 
Mike London
Ranch Hand
Posts: 1227
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After a lot of research, it appears that a lot of people (including me) are having "broken pipe" problems with Hibernate and MySQL after the typical 8 hour timeout period. Hibernate does not apparently handle this problem for us.

One possible posted solution that I'm trying to try is to use C3PO, the connection pool from sourceforge.

However, when I add the c3po configuration to my Hibernate config file, I get an "invalid configuration" error:

"org.xml.sax.SAXParseException: The content of element type "session-factory" must match "(property*,mapping*,(class-cache|collection-cache)*,event*,listener*)"."

My "invalid" Hibernate Configuration file is below.

***************************************************************
Also, do I need to modify my Hibernate code to actually "use" C3P0 or is it "automatic" via the Hibernate Config file?
***************************************************************

Thanks to all in advance.

Mike

------------------------------

<hibernate-configuration>

<session-factory>
<property name="connection.username">users</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/users
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.show.sql">true</property>
<property name="myeclipse.connection.profile">
MySQL Users
</property>
<property name="connection.password"></property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<mapping
resource="testProject/Uservisithistory.hbm.xml" />
<mapping resource="testProject/Users.hbm.xml" />

<property name="hibernate.c3p0.max_size">1</property>
<property name="hibernate.c3p0.min_size">0</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">100</property>
<property name="hibernate.c3p0.idle_test_period">300</property>
<property name="hibernate.c3p0.acquire_increment">2</property>

</session-factory>

</hibernate-configuration>
 
Mike London
Ranch Hand
Posts: 1227
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I got C3PO working, it appears to be automatic.

I had forgotten to add the "provider" statement to the config.

Hopefully, this will fix the MySQL timeout errors that Hibernate doesn't handle by default.

I'll post back.

Mike
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic