Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hibernate timeout

 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys : Is there a way to set a hibernate database connection timeout, i.e.

[code]
Configuration c = ...
c.setProperty("hibernate.show_sql", "true");
c.setProperty("use_sql_comments","true");
c.setProperty("hibernate.timeout", "10");
[code]

?

I have an application that uses hibernate, that hangs for a very long time when the database isnt installed... I'd rather just have it throw a timeout exception.


Thanks
Jay
 
Pierre Henry
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

You should try to throw a timeout exception at jdbc level.
 
Saket Chauhan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
:roll: :roll:
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK thanks ... how can i configure my jdbc driver that is used by hibernate to throw an timeout exception ? I'm using the commonly used Mysql jdbc driver (com.mysql.jdbc.Driver) class.
 
jay vas
Ranch Hand
Posts: 407
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have solved this problem by extending ConnectionProvider.... Anyone needing the code to do so feel free to email me.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!