-->
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.  [ 15 posts ] 
Author Message
 Post subject: Hibernate & mysql connection after connection closed.
PostPosted: Thu Mar 11, 2004 7:22 am 
Beginner
Beginner

Joined: Wed Nov 19, 2003 3:08 pm
Posts: 20
Hi!

I use hibernate in my web application, and got couple times following exception, after my computer has been idle over night, and started use application again next day.

Exception will disappear, if i install program again to tomcat, but that's really isn't any solution.

Mar 11, 2004 1:13:59 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: 08003
Mar 11, 2004 1:13:59 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: No operations allowed after connection closed
Mar 11, 2004 1:13:59 PM net.sf.hibernate.JDBCException <init>
SEVERE: Could not execute query
java.sql.SQLException: No operations allowed after connection closed
at com.mysql.jdbc.Connection.checkClosed(Connection.java:2497)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1287)
at com.mysql.jdbc.Connection.prepareStatement(Connection.java:1267)
at net.sf.hibernate.impl.BatcherImpl.getPreparedStatement(BatcherImpl.java:228)
at net.sf.hibernate.impl.BatcherImpl.prepareQueryStatement(BatcherImpl.java:61)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:703)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:184)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132)
at net.sf.hibernate.loader.Loader.doList(Loader.java:949)
at net.sf.hibernate.loader.Loader.list(Loader.java:940)
at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:833)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1475)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at fi.canter.adeona.web.actions.Login.handle2(Login.java:59)
at fi.canter.adeona.web.actions.Login.handle(Login.java:36)
at fi.canter.adeona.web.actions.Action.performAction(Action.java:16)
at fi.canter.adeona.web.RunData.handleAction(RunData.java:180)
at fi.canter.adeona.web.RunData.handle(RunData.java:125)
at fi.canter.adeona.web.RunData.<init>(RunData.java:50)
at fi.canter.adeona.web.servlets.MainServlet.service(MainServlet.java:56)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
at fi.canter.adeona.web.servlets.filters.MainFilter.doFilter(MainFilter.java:66)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:233)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:195)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)

hibernate-configuration:
<property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="connection.pool_size">10</property>
<property name="connection.url">jdbc:mysql://localhost:3306/---</property>
<property name="connection.username">---</property>
<property name="connection.password">---</property>
<property name="show_sql">false</property>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>

hibernate version 2.1.1
mysql driver: mysql-connector-java-3.0.8-stable-bin

Both are from www.ibiblio.com/maven. (i use maven)

Any hints?!??

Regards, Artsi


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 7:28 am 
Newbie

Joined: Wed Mar 10, 2004 11:46 pm
Posts: 7
Location: china
Post the detail at fi.canter.adeona.web.actions.Login.handle2(Login.java:59)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 7:35 am 
Beginner
Beginner

Joined: Wed Nov 19, 2003 3:08 pm
Posts: 20
handle is original, in handle2 i have ripped query, and other data, but problem occurs also every place, if i try to use hibernate, after it has been idle many hours..

public class Login extends Action
{
public void handle() throws Exception
{
Session session = HibernateService.currentSession();
Transaction t = session.beginTransaction();

try
{
handle2(session);
t.commit();
}
catch (Exception e)
{
t.rollback();
e.printStackTrace();
throw e;
}
finally
{
HibernateService.closeSession();
}
}

private void handle2(Session session)
throws Exception
{
List values = session.createQuery(....).list();
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 7:44 am 
Beginner
Beginner

Joined: Wed Nov 19, 2003 3:08 pm
Posts: 20
Does anybody has a experience about adding ?autoReconnect=true or ?autoReconnectForPools=true to connection.url??


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 8:14 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
what connection pool are you using?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 8:25 am 
Beginner
Beginner

Joined: Wed Nov 19, 2003 3:08 pm
Posts: 20
Actually i haven't defined any pool, just hibernates default.
Following is from tomcat log:

Mar 11, 2004 1:56:23 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Mar 11, 2004 1:56:23 PM net.sf.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 10

.. yes i see now that it isnt for production use.. =)
I will change it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 8:31 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
[quote]The Hibernate builtin JDBC connection pool no longer supports caching of PreparedStatements, so it is more important now to not use it in production systems. Use the Datasources provided by your Application Server or the DBCP, C3P0 or the Proxool JDBC connection pool.
[/code]

http://www.hibernate.org/68.html

i advise you using proxool since DBCP seems to have bug and they are many posts about C3P0...
proxool seems to be the best choice


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 8:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I personally think that c3p0 is a good choice. There are more posts about it because more people are using it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 8:36 am 
Beginner
Beginner

Joined: Wed Nov 19, 2003 3:08 pm
Posts: 20
Ok. I will check proxool.Thank you for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 8:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I would steer clear of DBCP, however.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 8:37 am 
Beginner
Beginner

Joined: Wed Nov 19, 2003 3:08 pm
Posts: 20
yes.. i will compare all those three, maby i'm lucky, and get best one.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 8:39 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
gavin wrote:
I would steer clear of DBCP, however.

Excuse me, what does that mean?, my english is bad


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 8:41 am 
Beginner
Beginner

Joined: Wed Nov 19, 2003 3:08 pm
Posts: 20
my is too. this is from www.m-w.com =)
Function: verb
Etymology: Middle English steren, from Old English stIeran; akin to Old English stEor- steering oar, Greek stauros stake, cross, stylos pillar, Sanskrit sthavira, sthura stout, thick
transitive senses
1 : to control the course of : DIRECT; especially : to guide by mechanical means (as a rudder)
2 : to set and hold to (a course)
intransitive senses
1 : to direct the course (as of a ship or automobile)
2 : to pursue a course of action
3 : to be subject to guidance or direction <an automobile that steers well>
synonym see GUIDE


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 8:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
LOL

"steer clear of" means same as "stay away from"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 9:16 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
Thanks to Hibernate team, i'm improving my English :))


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 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.