Hi all,
Sorry but I'm probably blind. I want to disable the use of Hibernate in my application if it will "probably" not work properly p.e. no connection to the database can be created.
I could use JDBC in order to test the connection to the database. However, the parameters of the connection are in hibernate.cfg.xml. So I guess Hibernate should be able to return the connection state. If I shutdown my database engine, the SessionFactory get still initialized (buildSessionFactory() does not throw any exception). I have tried to open a session with openSession(). Still no exception. However, I get lots of exceptions from C3P0 in the logs.
So, how to check if the database is available?
I'm using C3P0 with a MySQL database.
Thank you
P.S. I just think about the "hbm2ddl.auto" property. I will test this now but maybe there are other solutions.
|