Welcome to dbForumz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

setQueryTimeout not working

 
   Database Forums (Home) -> JDBC Driver RSS
Next:  FileMaker 7 IWP problem  
Author Message
Ruben Hesselbk

External


Since: Aug 03, 2004
Posts: 1



(Msg. 1) Posted: Tue Aug 03, 2004 9:54 am
Post subject: setQueryTimeout not working
Archived from groups: microsoft>public>sqlserver>jdbcdriver (more info?)

Does setQueryTimeout work in the latest JDBC driver ?

We have a tool that executes some queries, but the first couple of queries
timeout just after the connection has been established.
Each query is tried 3 times and each time the QueryTimeout is doubled (300
seconds default), and everything below happens in the same synchronized
block.

The first 3 columns are DATE TIME and ms, so how can the JDBC driver claim
that the query timed out within the same milisecond ?
Totally during the 3 retries 2100 seconds should have been used, but as you
can see in the logs only 78ms were actually used

040803 145706 0632 EV report connectToSQLServer Connected to SQL server
succesfully ##[
040803 145706 0695 ER report executeQuery caught exception while
executing [select * from TABLE where 1=2] with timeout
[300]java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]Execution timeout expired.
##[pi=Tomcat,ti=HttpProcessor[80][4],cr=platform.report.util.CoreLogAdapter.
log(CoreLogAdapter.java:74)
040803 145706 0695 EV report executeQuery Setting new timeout [600] ##[
040803 145706 0710 ER report executeQuery caught exception while
executing [select * from TABLE where 1=2] with timeout
[300]java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]Execution timeout expired.
##[pi=Tomcat,ti=HttpProcessor[80][4],cr=platform.report.util.CoreLogAdapter.
log(CoreLogAdapter.java:74)
040803 145706 0710 EV report executeQuery Setting new timeout [1200] ##[
040803 145706 0710 ER report executeQuery caught exception while
executing [select * from TABLE where 1=2] with timeout
[300]java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]Execution timeout expired.
##[pi=Tomcat,ti=HttpProcessor[80][4],cr=platform.report.util.CoreLogAdapter.
log(CoreLogAdapter.java:74)
040803 145706 0710 EV report executeQuery Setting new timeout [2400] ##[
040803 145706 0710 ER report executeQuery failed after 3 retries (cause
exception: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]Execution timeout expired.)

Here is the code

for (int retry = 1; retry <= retries; retry += 1) {
try {
statement.setQueryTimeout(timeout);
rs = statement.executeQuery(sql);
return rs;
} catch (SQLException e) {
if (rs != null) {
try {
while (rs.next());
} catch (SQLException ex) {
}
finally {
try {
rs.close();
}
catch (SQLException ex) {
}
}
rs = null;
}
log.error("executeQuery", "caught exception while executing
["+sql+"] with timeout ["+timeout+"]" + e);
// double sqltimeout for next try
timeout = timeout * 2;
log.event("executeQuery", "Setting new timeout [" + timeout +"]");
}
}

Hope someone can help

/Ruben

 >> Stay informed about: setQueryTimeout not working 
Back to top
Login to vote
Sue Purkis

External


Since: Nov 21, 2003
Posts: 16



(Msg. 2) Posted: Fri Aug 13, 2004 9:14 am
Post subject: Re: setQueryTimeout not working [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Rueben,
I used your code snippet in one of my programs and it worked as
expected. Can you share the rest of your code and connection options,
so I can compare what I have with what you have?

Thanks.

Sue Purkis
DataDirect Technologies.

"Ruben Hesselbęk" wrote in message ...
 > Does setQueryTimeout work in the latest JDBC driver ?
 >
 > We have a tool that executes some queries, but the first couple of queries
 > timeout just after the connection has been established.
 > Each query is tried 3 times and each time the QueryTimeout is doubled (300
 > seconds default), and everything below happens in the same synchronized
 > block.
 >
 > The first 3 columns are DATE TIME and ms, so how can the JDBC driver claim
 > that the query timed out within the same milisecond ?
 > Totally during the 3 retries 2100 seconds should have been used, but as you
 > can see in the logs only 78ms were actually used
 >
 > 040803 145706 0632 EV report connectToSQLServer Connected to SQL server
 > succesfully ##[
 > 040803 145706 0695 ER report executeQuery caught exception while
 > executing [select * from TABLE where 1=2] with timeout
 > [300]java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
 > JDBC]Execution timeout expired.
 > ##[pi=Tomcat,ti=HttpProcessor[80][4],cr=platform.report.util.CoreLogAdapter.
 > log(CoreLogAdapter.java:74)
 > 040803 145706 0695 EV report executeQuery Setting new timeout [600] ##[
 > 040803 145706 0710 ER report executeQuery caught exception while
 > executing [select * from TABLE where 1=2] with timeout
 > [300]java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
 > JDBC]Execution timeout expired.
 > ##[pi=Tomcat,ti=HttpProcessor[80][4],cr=platform.report.util.CoreLogAdapter.
 > log(CoreLogAdapter.java:74)
 > 040803 145706 0710 EV report executeQuery Setting new timeout [1200] ##[
 > 040803 145706 0710 ER report executeQuery caught exception while
 > executing [select * from TABLE where 1=2] with timeout
 > [300]java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
 > JDBC]Execution timeout expired.
 > ##[pi=Tomcat,ti=HttpProcessor[80][4],cr=platform.report.util.CoreLogAdapter.
 > log(CoreLogAdapter.java:74)
 > 040803 145706 0710 EV report executeQuery Setting new timeout [2400] ##[
 > 040803 145706 0710 ER report executeQuery failed after 3 retries (cause
 > exception: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
 > JDBC]Execution timeout expired.)
 >
 > Here is the code
 >
 > for (int retry = 1; retry <= retries; retry += 1) {
 > try {
 > statement.setQueryTimeout(timeout);
 > rs = statement.executeQuery(sql);
 > return rs;
 > } catch (SQLException e) {
 > if (rs != null) {
 > try {
 > while (rs.next());
 > } catch (SQLException ex) {
 > }
 > finally {
 > try {
 > rs.close();
 > }
 > catch (SQLException ex) {
 > }
 > }
 > rs = null;
 > }
 > log.error("executeQuery", "caught exception while executing
 > ["+sql+"] with timeout ["+timeout+"]" + e);
 > // double sqltimeout for next try
 > timeout = timeout * 2;
 > log.event("executeQuery", "Setting new timeout [" + timeout +"]");
 > }
 > }
 >
 > Hope someone can help
 >
 > /Ruben

 >> Stay informed about: setQueryTimeout not working 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
JDBC Driver for SQL 7.0 ? - Hi; I'm installing an application that requires a JDBC driver for SQL Server. The thing is I am running SQL Server 7.0 and a look at Microsoft seems to show there are lots of these drivers for SQL 2000 but not for 7.0 I know little about these things -...

JDBC driver conflict with "System.in.read();"????????????? - Hi; I'm writing a application which access the SQL SERVER 2000 by "SQL SERVER Driver for JDBC SP3". I create a thread class to fecth data from database,code like blow: public class DBThread extends Thread{ public void run(){...

using applet it is throwing exception - when i try to access database using applet it is throwing following exception with oracle 9.2 driver Database Exception:java.security.AccessControlException: access denied (java.util.PropertyPermission oracle.jserver.version read) it is throwing..

Multiple ResultSets - Hi I have a stored procedure which returns mulitple resultsets rs = call.executeQuery(); call.getMoreResults(); irs = call.getResultSet(); I want to pass these two resultsets to another method. When i pass these two i get error saying "ResultSet ...

JDBC or ODBC? - I am in the interesting position of having to choose between using an ODBC or JDBC connection for a high traffic site. We can develop on either environment though I prefer the Java based one. Database connectivity to our SQL 2000 server is our numbe...
   Database Forums (Home) -> JDBC Driver All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]