Mike - 11 months ago 83
Java Question

# How to configure connection timeout in hibernate?

I'm using Hibernate v4.1.4.final.jar using Java 1.7 to connect to Oracle 10g server. And this is a standalone java program.

Unfortunately, my query takes more than 30 minutes to run. I want to know where I can configure connection time out & read time out so that while running this standalone program, it will not time out and throw error?

Thanks!

1. If the jdbc driver that you use support timeout function and can be configured through property, then you can pass on the property using: hibernate.connection.<propertyname>
3. Configure your hibernate to use DataSource instead of plain Connection and control timeout through that.
The closest property that I can find for Oracle driver is oracle.jdbc.ReadTimeout property. So in your hibernate configuration, the whole name will be hibernate.connection.oracle.jdbc.ReadTimeout..hope this works for you.