Hi all,
I use hibernate in standalone (swing) application. Application is using contextual sessions and context is configured as ThreadLocalSessionContext. I need to test database connections therefore I wanted to use:
Code:
Session s = factory.getCurrentSession();
Transaction tx = s.beginTransaction();
connectionOK = s.isConnected() && !s.connection().isClosed();
tx.commit();
I am using c3p0 to pool connections. But if network connection is lost, thread that runs this code is blocked on line
s.beginTransaction and I have SQLException messages in log comming from c3p0.
Does anyone has a glue what to do or what is
the best method to test connection?