<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Problem with Hibernate, c3p0, mysql - Java Monkeys - tribe.net</title>
    <link>http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986?format=rss</link>
    <description>Tribe.net. Local Connections</description>
    <item>
      <title>Re: Problem with Hibernate, c3p0, mysql</title>
      <link>http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#0689513a-de13-4181-9256-aa0f644bb7f0</link>
      <description>Sorry, meant to ask:&#xD;
&#xD;
Did you have to change your MySQL JDBC driver?</description>
      <pubDate>Sat, 06 May 2006 15:55:17 GMT</pubDate>
      <guid isPermaLink="false">http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#0689513a-de13-4181-9256-aa0f644bb7f0</guid>
      <dc:creator>Bob</dc:creator>
      <dc:date>2006-05-06T15:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Hibernate, c3p0, mysql</title>
      <link>http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#abad3259-055e-45a0-9251-3057819ace4e</link>
      <description>Did you remember what settings did the trick?  Did you have to change your MySQL?</description>
      <pubDate>Sat, 06 May 2006 15:54:25 GMT</pubDate>
      <guid isPermaLink="false">http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#abad3259-055e-45a0-9251-3057819ace4e</guid>
      <dc:creator>Bob</dc:creator>
      <dc:date>2006-05-06T15:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Hibernate, c3p0, mysql</title>
      <link>http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#3a3a23e4-5961-4a31-b6d3-49de26f888b2</link>
      <description>Hi,&#xD;
&#xD;
I got tis problem some time ago and solved it with dbcp.&#xD;
Now I just migrated to hibernate 3 and I am getting that problem  again.&#xD;
&#xD;
What config did you use to solve your problem ?&#xD;
&#xD;
My dbcp config is the following :&#xD;
&#xD;
      &amp;amp;lt;!--connection pool--&gt; &#xD;
      &amp;amp;lt;property name="hibernate.dbcp.maxActive"&gt;10&amp;amp;lt;/property&gt; &#xD;
      &amp;amp;lt;property name="hibernate.dbcp.whenExhaustedAction"&gt;1&amp;amp;lt;/property&gt; &#xD;
      &amp;amp;lt;property name="hibernate.dbcp.maxWait"&gt;20000&amp;amp;lt;/property&gt; &#xD;
      &amp;amp;lt;property name="hibernate.dbcp.maxIdle"&gt;10&amp;amp;lt;/property&gt; &#xD;
&#xD;
      &amp;amp;lt;!-- prepared statement cache--&gt; &#xD;
      &amp;amp;lt;property name="hibernate.dbcp.ps.maxActive"&gt;10&amp;amp;lt;/property&gt; &#xD;
      &amp;amp;lt;property name="hibernate.dbcp.ps.whenExhaustedAction"&gt;1&amp;amp;lt;/property&gt; &#xD;
      &amp;amp;lt;property name="hibernate.dbcp.ps.maxWait"&gt;20000&amp;amp;lt;/property&gt; &#xD;
      &amp;amp;lt;property name="hibernate.dbcp.ps.maxIdle"&gt;10&amp;amp;lt;/property&gt; &#xD;
&#xD;
      &amp;amp;lt;!-- optional query to validate pooled connections:--&gt; &#xD;
      &amp;amp;lt;property name="hibernate.dbcp.validationQuery"&gt;select 1&amp;amp;lt;/property&gt; &#xD;
      &amp;amp;lt;property name="hibernate.dbcp.testOnBorrow"&gt;true&amp;amp;lt;/property&gt; &#xD;
      &amp;amp;lt;property name="hibernate.dbcp.testOnReturn"&gt;true&amp;amp;lt;/property&gt; &#xD;
&#xD;
thanks</description>
      <pubDate>Sat, 18 Mar 2006 18:33:14 GMT</pubDate>
      <guid isPermaLink="false">http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#3a3a23e4-5961-4a31-b6d3-49de26f888b2</guid>
      <dc:creator>slepit</dc:creator>
      <dc:date>2006-03-18T18:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Hibernate, c3p0, mysql</title>
      <link>http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#63b06303-9426-47b1-961f-817d3968c903</link>
      <description>w00t! &#xD;
After a bit of testing and trying a few different suggestions provided in both links i have got this problem licked.&#xD;
&#xD;
Thanks Noah.</description>
      <pubDate>Fri, 11 Nov 2005 05:27:57 GMT</pubDate>
      <guid isPermaLink="false">http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#63b06303-9426-47b1-961f-817d3968c903</guid>
      <dc:creator>$item.owner.firstName</dc:creator>
      <dc:date>2005-11-11T05:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Hibernate, c3p0, mysql</title>
      <link>http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#ef8a146d-d513-4bc4-ad34-bb07052e1b5e</link>
      <description>This problem has popped up multiple times in the Hibernate Users forum, so you're not alone. Here's a thread on it:&#xD;
&#xD;
http://forum.hibernate.org/viewtopic.php?t=943079&amp;amp;highlight=c3p0+connection+timeout&#xD;
&#xD;
I think that the relevant parameters to fix this problem in your c3p0 config are maxIdleTime, idleConnectionTestPeriod, preferredTestQuery and testConnectionOnCheckout, depending on what approach you want to take. See:&#xD;
&#xD;
http://www.mchange.com/projects/c3p0/index.html#idleConnectionTestPeriod&#xD;
&#xD;
...and related info on that page.</description>
      <pubDate>Mon, 31 Oct 2005 21:56:55 GMT</pubDate>
      <guid isPermaLink="false">http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#ef8a146d-d513-4bc4-ad34-bb07052e1b5e</guid>
      <dc:creator>Noah</dc:creator>
      <dc:date>2005-10-31T21:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Hibernate, c3p0, mysql</title>
      <link>http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#e28af254-8c7e-4d2b-9919-bc9f6bdbd927</link>
      <description>ok this did not work.  The pool lasts longer, but still eventually tanks.  This is definitely a problem with hibernate.  I've built tons of apps by programatically instanciating a dbcp connection pool that did not die.</description>
      <pubDate>Mon, 31 Oct 2005 00:15:50 GMT</pubDate>
      <guid isPermaLink="false">http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#e28af254-8c7e-4d2b-9919-bc9f6bdbd927</guid>
      <dc:creator>$item.owner.firstName</dc:creator>
      <dc:date>2005-10-31T00:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with Hibernate, c3p0, mysql</title>
      <link>http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#0d0d5cd5-e36d-4390-a1b6-174d075676e0</link>
      <description>I sort of found a solution.  I could not make c3p0 work, so i switched to a dbcp connection pool.  Hibernate 3 does not natively support dbcp so i used this code from the jakarta wiki:&#xD;
&#xD;
&#xD;
http://wiki.apache.org/jakarta-commons/DBCP/Hibernate</description>
      <pubDate>Fri, 28 Oct 2005 19:43:32 GMT</pubDate>
      <guid isPermaLink="false">http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#0d0d5cd5-e36d-4390-a1b6-174d075676e0</guid>
      <dc:creator>$item.owner.firstName</dc:creator>
      <dc:date>2005-10-28T19:43:32Z</dc:date>
    </item>
    <item>
      <title>Problem with Hibernate, c3p0, mysql</title>
      <link>http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#5fdea819-e529-466e-a633-9ffc29f8d99e</link>
      <description>I have a webapp that uses:&#xD;
hibernate 3.0&#xD;
the bundled c3p0 connection pool&#xD;
mysql 4.1.11&#xD;
on Debian Linux&#xD;
under Resin 3.x&#xD;
&#xD;
My problem:&#xD;
When the webapp is deployed c3p0 creates the connection pool and everything works as expected.  After about 12-24 hrs of leaving it running on a test server, i try to access the application again and get an error message that looks like the pool cannot get a connection.  Below is the full stack trace:&#xD;
&#xD;
java.sql.SQLException: Communication link failure: java.io.EOFException,&#xD;
underlying cause: null&#xD;
&#xD;
** BEGIN NESTED EXCEPTION ** &#xD;
&#xD;
java.io.EOFException&#xD;
&#xD;
STACKTRACE:&#xD;
&#xD;
java.io.EOFException&#xD;
	at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1394)&#xD;
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1538)&#xD;
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1929)&#xD;
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)&#xD;
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)&#xD;
	at com.mysql.jdbc.Connection.execSQL(Connection.java:2247)&#xD;
	at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1586)&#xD;
	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:75)&#xD;
	at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)&#xD;
	at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)&#xD;
	at org.hibernate.loader.Loader.doQuery(Loader.java:391)&#xD;
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)&#xD;
	at org.hibernate.loader.Loader.doList(Loader.java:1593)&#xD;
	at org.hibernate.loader.Loader.list(Loader.java:1577)&#xD;
	at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)&#xD;
	at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)&#xD;
	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)&#xD;
	at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)&#xD;
	at mofobox.logic.UserManager.isValidUser(Unknown Source)&#xD;
	at mofobox.logic.UserManager.isValidUser(Unknown Source)&#xD;
	at mofobox.actions.LoginSubmitAction.execute(Unknown Source)&#xD;
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)&#xD;
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)&#xD;
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)&#xD;
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)&#xD;
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:154)&#xD;
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)&#xD;
	at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:99)&#xD;
	at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:163)&#xD;
	at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:208)&#xD;
	at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:259)&#xD;
	at com.caucho.server.port.TcpConnection.run(TcpConnection.java:363)&#xD;
	at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:490)&#xD;
	at com.caucho.util.ThreadPool.run(ThreadPool.java:423)&#xD;
	at java.lang.Thread.run(Thread.java:595)&#xD;
&#xD;
&#xD;
** END NESTED EXCEPTION **&#xD;
&#xD;
&#xD;
	at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1713)&#xD;
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1929)&#xD;
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1167)&#xD;
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1278)&#xD;
	at com.mysql.jdbc.Connection.execSQL(Connection.java:2247)&#xD;
	at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1586)&#xD;
	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:75)&#xD;
	at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)&#xD;
	at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)&#xD;
	at org.hibernate.loader.Loader.doQuery(Loader.java:391)&#xD;
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)&#xD;
	at org.hibernate.loader.Loader.doList(Loader.java:1593)&#xD;
	at org.hibernate.loader.Loader.list(Loader.java:1577)&#xD;
	at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)&#xD;
	at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)&#xD;
	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)&#xD;
	at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)&#xD;
	at mofobox.logic.UserManager.isValidUser(Unknown Source)&#xD;
	at mofobox.logic.UserManager.isValidUser(Unknown Source)&#xD;
	at mofobox.actions.LoginSubmitAction.execute(Unknown Source)&#xD;
	at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)&#xD;
	at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)&#xD;
	at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)&#xD;
	at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)&#xD;
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:154)&#xD;
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:92)&#xD;
	at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:99)&#xD;
	at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:163)&#xD;
	at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:208)&#xD;
	at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:259)&#xD;
	at com.caucho.server.port.TcpConnection.run(TcpConnection.java:363)&#xD;
	at com.caucho.util.ThreadPool.runTasks(ThreadPool.java:490)&#xD;
	at com.caucho.util.ThreadPool.run(ThreadPool.java:423)&#xD;
	at java.lang.Thread.run(Thread.java:595)&#xD;
&#xD;
&#xD;
&#xD;
&#xD;
Relevant portions of my hibernate.cfg.xml are as follows:&#xD;
&#xD;
&#xD;
&#xD;
  &amp;amp;lt;!-- Database connection settings --&gt;&#xD;
        &amp;amp;lt;property name="connection.driver_class"&gt;com.mysql.jdbc.Driver&amp;amp;lt;/property&gt;&#xD;
        &amp;amp;lt;property name="connection.url"&gt;jdbc:mysql://192.168.1.3/mp3&amp;amp;lt;/property&gt;&#xD;
        &amp;amp;lt;property name="connection.username"&gt;foo&amp;amp;lt;/property&gt;&#xD;
        &amp;amp;lt;property name="connection.password"&gt;bar&amp;amp;lt;/property&gt;&#xD;
&#xD;
&#xD;
        &amp;amp;lt;!-- c3p0 connection pool properties --&gt;&#xD;
        &amp;amp;lt;property name="hibernate.c3p0.max_size"&gt;20&amp;amp;lt;/property&gt;&#xD;
        &amp;amp;lt;property name="hibernate.c3p0.timeout"&gt;1800&amp;amp;lt;/property&gt;&#xD;
        &amp;amp;lt;property name="hibernate.c3p0.max_statements"&gt;0&amp;amp;lt;/property&gt;&#xD;
        &amp;amp;lt;property name="hibernate.c3p0.idle_test_period"&gt;-1&amp;amp;lt;/property&gt;&#xD;
        &amp;amp;lt;property name="hibernate.c3p0.min_size"&gt;5&amp;amp;lt;/property&gt;&#xD;
&#xD;
I am also using the HibernateUtil code from the hibernate documentation:&#xD;
&#xD;
public class SessionManager {&#xD;
&#xD;
    public static final SessionFactory sessionFactory;&#xD;
&#xD;
    static {&#xD;
        try {&#xD;
            // Create the SessionFactory from hibernate.cfg.xml&#xD;
            sessionFactory = new Configuration().configure().buildSessionFactory();&#xD;
        } catch (Throwable ex) {&#xD;
            // Make sure you log the exception, as it might be swallowed&#xD;
            System.err.println("Initial SessionFactory creation failed." + ex);&#xD;
            throw new ExceptionInInitializerError(ex);&#xD;
        }&#xD;
    }&#xD;
&#xD;
    public static final ThreadLocal sessionThreadLocal = new ThreadLocal();&#xD;
&#xD;
    public static Session currentSession() throws HibernateException {&#xD;
        Session s = (Session) sessionThreadLocal.get();&#xD;
        // Open a new Session, if this thread has none yet&#xD;
        if (s == null || (!s.isConnected())) {&#xD;
            s = sessionFactory.openSession();&#xD;
            // Store it in the ThreadLocal variable&#xD;
            sessionThreadLocal.set(s);&#xD;
        }&#xD;
        return s;&#xD;
    }&#xD;
&#xD;
    public static void closeSession() throws HibernateException {&#xD;
        Session s = (Session) sessionThreadLocal.get();&#xD;
        if (s != null)&#xD;
            s.close();&#xD;
        sessionThreadLocal.set(null);&#xD;
    }&#xD;
&#xD;
&#xD;
If i redeploy the webapp everything works, for about a day, then the same problem.&#xD;
&#xD;
Any ideas?</description>
      <pubDate>Fri, 28 Oct 2005 07:04:01 GMT</pubDate>
      <guid isPermaLink="false">http://javamonkeys.tribe.net/thread/0f805ec1-c8e1-4cb1-90ed-8474afc1d986#5fdea819-e529-466e-a633-9ffc29f8d99e</guid>
      <dc:creator>$item.owner.firstName</dc:creator>
      <dc:date>2005-10-28T07:04:01Z</dc:date>
    </item>
  </channel>
</rss>



