| Author |
Hibernate Swallowing Connection Exceptions
|
Benjamin Lambe
Greenhorn
Joined: Jul 04, 2007
Posts: 7
|
|
Hi,
I have a server running Hibernate, using C3P0 as a connection pool. When I start up my application, if the MySQL server is down when i start the application using
new Configuration().configure().buildSessionFactory();
I get the following error
Caused by: java.net.ConnectException: Connection refused: connect
but this seems to be getting caught and printed by C3P0 or Hibernate itself and not let me catch it. Is there any way, such as a setting in hibernate.cfg.xml to allow me to catchi this myself. I have put a try catch around buildSessionfactory() but nothing ever propogates up to this method call.
Thanks in advance
Ben
|
 |
Benjamin Lambe
Greenhorn
Joined: Jul 04, 2007
Posts: 7
|
|
setting acquireRetryAttempts in the c3p0 properties for hibernate.xfg.xml seemed to get rid of this problem for me.
been trying things the last hour, then as soon as i post this i fugure it out lol
hope this helps anybody else.....
|
 |
Manuel Petermann
Ranch Hand
Joined: Jul 19, 2011
Posts: 175
|
|
Could you please post your c3p0.properties, hibernate.cfg.xml and a small code fragment of your configure() try-catch block?
I tried to catch a wrong password and i believe my error is similar to yours.
Thanks in advance.
|
Please correct my English.
|
 |
Manuel Petermann
Ranch Hand
Joined: Jul 19, 2011
Posts: 175
|
|
I sort of fixed the problem by using the doWork() method like:
Thing is, I really hate it to use dummy code just to get an exception. Is there any other way or is this the way to go?
|
 |
 |
|
|
subject: Hibernate Swallowing Connection Exceptions
|
|
|