-->
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.  [ 1 post ] 
Author Message
 Post subject: How to close SessionFactory while using C3P0?
PostPosted: Mon Nov 22, 2004 11:43 am 
Beginner
Beginner

Joined: Mon Nov 22, 2004 11:21 am
Posts: 42
I have an application where the user can disconnect and connect to a different database. During "disconnect" I was using the method close() from SessionFactoryImpl to close the SessionFactory.

Since I switched to C3P0 I get an exception when calling close() on the SessionFactory as soon as have loaded any object from the database using hibernate. What's wrong? Do I miss something?

Thanks in advance,
Georgios Skempes

P.S.: I tried to debug, but the debug line numbers don't fit the executed lines of code. It seems the source code and the jar are slightly different.


Hibernate version:2.1.6

Mapping documents:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="show_sql">true</property>
<property name="dialect">net.sf.hibernate.dialect.FirebirdDialect</property>
<property name="connection.driver_class">org.firebirdsql.jdbc.FBDriver</property>
<property name="hibernate.query.substitutions">yes '1', no '0'</property>
<!-- Old parameters, now set during runtime (login screen)
<property name="connection.url">jdbc:firebirdsql:53.139.230.11/3050:migrationstool</property>
<property name="connection.username">sysdba</property>
<property name="connection.password">***</property>
-->
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.show_sql">true</property>
<!-- Mapping files -->
<mapping resource="com/tsystems/mighty/persistence/mappings/Casetransfer.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Chaintransfer.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Checkformatassignment.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Issue.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Key.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Keydirectory.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Mappingattributehistory.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Metaimport.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Metaimporterror.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Mightyparameter.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Parameterfilling.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Rule.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Ruleparameter.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Selecttransfer.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Sourcetable.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Sourcetableattribute.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Targettable.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Targettableattribute.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Workshop.hbm" />
<!-- (Ex-)Enumerator Mappings -->
<mapping resource="com/tsystems/mighty/persistence/mappings/Checkformattype.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Effortclassification.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/State.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Statetargettable.hbm" />
<mapping resource="com/tsystems/mighty/persistence/mappings/Transfertype.hbm" />
</session-factory>
</hibernate-configuration>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
org.firebirdsql.jdbc.FBSQLException: This statement is already closed.
at org.firebirdsql.jdbc.AbstractStatement.close(AbstractStatement.java:225)
at com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:38)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache$1.run(GooGooStatementCache.java:235)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:148)
org.firebirdsql.jdbc.FBSQLException: You cannot getAutomcommit on an unassociated closed connection.
at org.firebirdsql.jdbc.AbstractConnection.getAutoCommit(AbstractConnection.java:344)
at org.firebirdsql.jdbc.AbstractStatement.getSynchronizationObject(AbstractStatement.java:127)
at org.firebirdsql.jdbc.AbstractStatement.close(AbstractStatement.java:227)
at com.mchange.v1.db.sql.StatementUtils.attemptClose(StatementUtils.java:38)
at com.mchange.v2.c3p0.stmt.GooGooStatementCache$1.run(GooGooStatementCache.java:235)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:148)


Name and version of the database you are using:Firebird 1.5.1

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:error

_________________
Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25


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

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.