File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Query Time out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Query Time out " Watch "Query Time out " New topic

Query Time out

Manjesh Patil
Ranch Hand

Joined: Sep 24, 2010
Posts: 42

Hi ,
I am using Oracle JDBC Driver version - in my JDBC based utility program.
the problem is when query takes more than 20-30 minutes to return the resuts ,I face "Time out" error.

I have tried printing getQueryTimeOut(); which will print '0' (Zero) I have read from JDBC API doc that Zero indicates Driver will wait for any amount of time once the query starts executing..
but still I do face this issue.
Even tried to setTimeout to some 30 minutes converting into seconds then also no gain.
can anyone tell me the workaround to this..


Ed Ward
Ranch Hand

Joined: Jan 30, 2006
Posts: 147
Are you getting a SQLException or some other timeout oriented exception?

If the query itself is timing out then you should be getting a SQLException with a relevant message. You said the timeout is set to zero so it should not be timing out at all. However, there could be some other network or session config that is timing you out. I actually experienced a situtation where we thought a query was timing out but it turned out that there was a network config (I forgot exactly what it was) set to timeout due to inactivity. This timeout period happened to be shorter than the average execution time of our query; SQLException was not thrown in this case cause the SQL timeout did not happen. After we bumped it a bit all was fine.

What is the actual exception message thrown?

BTW, if your query is taking 30 plus minutes you may want to consider tuning it and/or the tables or database involved.
Manjesh Patil
Ranch Hand

Joined: Sep 24, 2010
Posts: 42

Hi Ed Ward,
thanks for replay

There is no SQLException trace just it says :
WARNING: Read timed out
not able to figure out where is this time period is defined .
tuning the query wont help me lot coz Its reported that even after 5 minutes the warning message appears [WARNING: Read timed out]
I tried with query which will take 1-2 minutes that works fine ,problem is with the queries which will take 5+ minutes

It is sorta covered in the JavaRanch Style Guide.
subject: Query Time out
It's not a secret anymore!