1

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!

Mike
  • 7,606
  • 25
  • 65
  • 82

2 Answers2

5

There are a few options that you can try:

  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>
  2. Use external connection provider such as c3p0 or DBCP, and control the timeout as those external provider support.
  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.

DJ.
  • 6,664
  • 1
  • 33
  • 48
  • DJ, I'm using Oracle JDBC driver called ojdbc14.jar for Oracle 10g. Do you have a code snippet to use timeout from this Jar? – Mike Jul 25 '12 at 06:01
  • What would be the equivalent for postgres? – faizan Aug 31 '17 at 05:26
  • @faizan, you need to find out from postgres's driver documentation, and apply the same rules as I wrote in the answer. – DJ. Sep 07 '17 at 00:48
0

By default it won't throw any kind of error, FWIW...if you run a query, it'll just work, AFAIK.

In terms of connect timeout, you may be able to specify in your

hibernate.connection.url a particular option for your DB, ex: Postgres I'd add &connectTimeout=0

rogerdpack
  • 62,887
  • 36
  • 269
  • 388