-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: C3PO connection pool goes stale/ not getting called?
PostPosted: Sun Mar 27, 2005 1:00 pm 
Regular
Regular

Joined: Mon Oct 20, 2003 3:14 am
Posts: 53
Location: Sterling, VA, USA
The FAQ for use with mySQL says to use C3P0 to avoid having Hibernate become unable to connect to the database after >hand waving< a while of inactivity. I do this.

This does the job nicely on my Windows dev box.

It however doesn't work so great when I deploy. The first query I try gives me an exception if nothing has happened for too long.

Using Hibernate 3.0 RC1 and C3P0 with MySQL 4.1.

hibernate.cfg.xml snippet:

Code:
        <property name="show_sql">true</property>
        <property name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
        <property name="connection.username">xxxxx</property>
        <property name="connection.password">xxxxx</property>
       <property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
       <property name="connection.url">jdbc:mysql://localhost:3306/xx</property>
       <property name="c3p0.minPoolSize">5</property>
       <property name="c3p0.maxPoolSize">20</property>
       <property name="c3p0.timeout">1800</property>
       <property name="c3p0.max_statement">50</property>
       <property name="hibernate.transaction.factory_class">
         org.hibernate.transaction.JDBCTransactionFactory
       </property>



Exception snippet follows. I find it curious no C3P0 code seems to get called. I assume this must mean I have a misconfiguration above.

Code:
java.io.EOFException
        at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1394)
        at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1538)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1929)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:2247)
        at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1586)
        at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:107)
        at org.hibernate.loader.Loader.getResultSet(Loader.java:1183)
        at org.hibernate.loader.Loader.doQuery(Loader.java:363)
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:203)
        at org.hibernate.loader.Loader.doList(Loader.java:1499)
        at org.hibernate.loader.Loader.list(Loader.java:1482)
        at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:111)
        at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1246)
        at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:299)

_________________
"A statistician is a mathmetician, broken down by age and sex".


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 29, 2005 6:29 am 
C3P0 Developer
C3P0 Developer

Joined: Tue Jan 06, 2004 8:58 pm
Posts: 145
Hi,

Your hibernate config should have

<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">20</property>

instead of...

<property name="c3p0.minPoolSize">5</property> <!-- bad puppy -->
<property name="c3p0.maxPoolSize">20</property> <!-- bad chicken -->

Please see http://www.mchange.com/projects/c3p0/in ... appendix_d for more info.

I gather from a comment on hibernate's wiki ( http://www.hibernate.org/214.html ) that hibernate looks for the presence of hibernate.c3p0.max_size in deciding whether to use c3p0, so this probably explains why hibernate didn't try to use c3p0 in your app. [Thx markmansour!]

smiles,
Steve


 


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 30, 2005 1:56 am 
Regular
Regular

Joined: Mon Oct 20, 2003 3:14 am
Posts: 53
Location: Sterling, VA, USA
Thank you. That fixed it.

I had cut and pasted that snippet from The Hibernate 2.1 manual some time back. I would not have had the C3P0 native property name otherwise...

_________________
"A statistician is a mathmetician, broken down by age and sex".


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.