I am running Spring + hibernate 3 + c3p0. Upon start up, if the database is down an exception is thrown after about 10 mins. Until then the program is blocked... I dont include spring xml, hibernate configuration etc, since it is a fairly common problem and if a solution exists it must be a standard straighforward way. If not i can trim the crucial code and configuration and paste it here. Does anybody know anything about it? Thanks in advance.
It's most likely not related to Hibernate / Spring per se; database connection pool is responsible for dealing with connections.
- What are your C3P0 settings?
- What database / driver are your using? Are there any driver-specific settings causing driver itself to wait / retry before reporting an error?
- Does "database down" mean "completely down"? Or could this be caused by some sort of socket timeout?
Update (based on OP clarification below):
DriverManager.setLoginTimeout()
is not used by the oracle driver. OracleDataSource has its own loginTimeout setting instead.
To clarify:
What I essentially need is to know if there is a wrapper in c3p0 or hibernate, or even spring, around the DriverManager.setLoginTimeout() function. Or a feature that offers me this functionality. The wrapper could be through a setting or something. I just want to get an exception if i havent connected to the datasource in X seconds, no matter the cause (socket, database, bad weather). And I want to find a place to set this X. To make things worse, Oracle driver , which is the driver i am using, does not implement setLoginTimeout() so I cant use it directly. I ve come to realize there is no way to solve it, but to manually spawn a timer thread of my own. Anybody can verify the above situation? Thanks a lot.