• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Hibernate and MySQL connection issues

 
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 1973
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic