-->
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: C3P0 not checking connections when opening sessions
PostPosted: Mon Jun 01, 2009 6:38 am 
Beginner
Beginner

Joined: Wed Nov 05, 2003 7:51 am
Posts: 22
I am using C3P0 0.9.1 as a connection pool for my Hibernate 3.2 application which is accessing a POstgreSQL 8.3 database.

The application is a rich-client Swing app which connects to the database directly over the internet.

Since PostgreSQL connections get broken quite often over the internet (never happens on the local net) we now would like to test our connections on checkout from the connection pool.

We configure Hibernate with C3P0, activating connection testing with the "validate" parameter:
hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider
hibernate.c3p0.min_size=0
hibernate.c3p0.initial_size=0
hibernate.c3p0.acquire_increment=1
hibernate.c3p0.validate=true

We also provide connection testing settings in the C3P0.properties file:
testConnectionOnCheckout=true
preferredTestQuery=select 1 from core_sys_settings


For some reason, we still get broken connections from the connection pool when using SessionFactory.openSession(), so the newly created Session is also broken. We test the connection-testing by forcibly killing the connections on the server (with kill PID) and see what happens on the client.

If I understand correctly, Hibernate checks out a connection for every newly opened session right? When it checks the connection out, C3P0 should test the connection as its configuration says. If it finds a broken connection, it should open a new and return the new connection for the session. Still, it doesn't seem to happen in every case.

Is it possible that Hibernate checks out a connection from the pool only in certain cases? How can I make sure, the connection gets tested during openSession() and I always get a working connection.


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.