Forums Register Login

Hibernate Swallowing Connection Exceptions

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.....
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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?
I got this tall by not having enough crisco in my diet as a kid. This ad looks like it had plenty of shortening:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1201 times.
Similar Threads
JBoss with C3P0 Connection Pool Config/Usage
Hibernate C3P0 connection pool provider
Switching[restarting] Database forces to restart application
Tomcat error --> org.hibernate.exception.JDBCConnectionException: Cannot open connection
How do I use hbm2ddl correctly?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:17:46.