Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate Swallowing Connection Exceptions

 
Matthew Shapiro
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Matthew Shapiro
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 177
Hibernate Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Manuel Petermann
Ranch Hand
Posts: 177
Hibernate Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic