-->
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: connection closed (Hibernate 1.2)
PostPosted: Thu Sep 11, 2003 1:00 pm 
Beginner
Beginner

Joined: Thu Sep 11, 2003 12:53 pm
Posts: 23
Hi,

I've a web app developed with Hibernate 1.2. When a user tries to log in after a long period of inactivity, I get the following exception:

java.sql.SQLException: No operations allowed after connection closed

I understand that MySql shuts off connections after 8 hours. I tried setting the DBCP validation query, and even specifying the "autoreconnect" parameter in the JDBC URL. No luck. Anyone have any ideas?

Code:
hibernate.dbcp.validationQuery = Select 1

hibernate.dialect = cirrus.hibernate.sql.MySQLDialect
hibernate.connection.driver_class = com.mysql.jdbc.Driver
hibernate.connection.username =XXX
hibernate.connection.password =XXX
hibernate.connection.url = jdbc:mysql://localhost/dbname?autoReconnect=true


P.S. This seems to work ok in my Hibernate 2.0.2 based app. I'm reluctant to spend the effort to upgrade this older project unless I really need to, though.

Thanks, WILL


Top
 Profile  
 
 Post subject: Happens with Hibernate 2 too
PostPosted: Wed Oct 08, 2003 2:53 am 
Newbie

Joined: Thu Sep 25, 2003 9:25 am
Posts: 15
I have exactly the same problem with Hibernate 2. I'm using dbcp connection pooling:

hibernate.dbcp.ps.maxActive = 100
hibernate.dbcp.ps.maxIdle = 100
hibernate.dbcp.ps.maxWait = 120000
hibernate.dbcp.ps.whenExhaustedAction = 0
hibernate.dbcp.maxActive = 100
hibernate.dbcp.maxIdle = 10
hibernate.dbcp.maxWait = 120000
hibernate.dbcp.whenExhaustedAction = 0

with MySQL:

hibernate.connection.url = jdbc:mysql://myhost:3306/mydb?autoReconnect=true

The error happens after some time of inactivity (eg. over night):

net.sf.hibernate.JDBCException: Could not load object: Connection.close() has already been called. Invalid operation in this state.

Any ideas? Thanks.


Top
 Profile  
 
 Post subject: Re: Happens with Hibernate 2 too
PostPosted: Thu Oct 09, 2003 3:20 am 
Newbie

Joined: Thu Oct 09, 2003 2:52 am
Posts: 6
Are you using 3.x version of mysql connector? There's a new feature added to the connector that prevents autoReconnect from working if autoCommit is set to false. That's because reconnecting when autoCommit is false can lead to a non-consistent db state.

Try adding query validation to your pooled connections:

Code:
hibernate.dbcp.validationQuery select 1
hibernate.dbcp.testOnBorrow true
hibernate.dbcp.testOnReturn true


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.