Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Bugs > Re: BUG #4123: ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 8 Topic 3726 of 4089
Post > Topic >>

Re: BUG #4123: Statement.setQueryTimeout does not work with Postgres

by valgog <valgog@[EMAIL PROTECTED] > Apr 23, 2008 at 03:52 AM

On Apr 22, 12:05=A0pm, amit.muja...@[EMAIL PROTECTED]
 ("Amit Mujawar") wrote:
> The following bug has been logged online:
>
> Bug reference: =A0 =A0 =A04123
> Logged by: =A0 =A0 =A0 =A0 =A0Amit Mujawar
> Email address: =A0 =A0 =A0amit.muja...@[EMAIL PROTECTED]
> PostgreSQL version: 8.1
> Operating system: =A0 Windows XP
> Description: =A0 =A0 =A0 =A0Statement.setQueryTimeout does not work with
P=
ostgres
> Java Driver
> Details:
>
> I am using PostgreSQL through JDBC
> PostgreSQL =96 8.1, Driver - org.postgresql.Driver 8.1-408.jdbc3
>
> When I set Statement.setQueryTimeout, the timeout value does not show
any
> effect on actual timeout...The query blocks for a specific time always
[ma=
y
> be configured by another global variable - statement_timeout? not sure]
>
> I suspect there is a problem with JDBC driver implementation for
> setQueryTimeout API.
>

It is in the TODO list of the driver to be implemented. Actually the
TODO list for Postgres JDBC It is a good place to see what the
features you cannot use :-)

I am setting the timeout by the acquisition of the connection by the
pool (in ConnectionCustomizer in C3P0 pooling library) like that:

PreparedStatement s =3D null;
ResultSet rs =3D null;
try {
  s =3D c.prepareStatement("SELECT set_config('statement_timeout', ?,
false);" );
  s.setInt(1, 35000);
  rs =3D s.executeQuery();
  if ( rs.next() ) {
    String newTimeout =3D rs.getString(1);
    if ( logger.isInfoEnabled() ) {
      logger.info("STATEMENT_TIMEOUT set to '" + newTimeout + "' (" +
parentDataSourceIdentityToken + ")");
    }
  } else {
    if ( logger.isErrorEnabled() ) {
      logger.error("STATEMENT_TIMEOUT could not be set! (" +
parentDataSourceIdentityToken + ")");
    }
  }
} catch (SQLException e) {
  if ( logger.isErrorEnabled() ) {
    logger.error("STATEMENT_TIMEOUT could not be set! (" +
parentDataSourceIdentityToken + ")", e);
  }
} finally {
  if ( rs !=3D null ) rs.close();
  if ( s !=3D null ) s.close();
}

if you want to do it before you start some transaction, you can bring
this code into a function like Utils.setStatementTimeout(Connection c,
boolean isTransactionLocal) and call it after
Connection.setAutoCommit(false);
 




 8 Posts in Topic:
BUG #4123: Statement.setQueryTimeout does not work with Postgres
amit.mujawar@[EMAIL PROTE  2008-04-22 10:05:03 
Re: BUG #4123: Statement.setQueryTimeout does not work with
books@[EMAIL PROTECTED]   2008-04-22 11:53:19 
Re: BUG #4123: Statement.setQueryTimeout does not work with Post
valgog <valgog@[EMAIL   2008-04-23 03:52:11 
Re: BUG #4123: Statement.setQueryTimeout does not work with Post
valgog <valgog@[EMAIL   2008-04-23 03:59:03 
Re: Re: BUG #4123: Statement.setQueryTimeout does not work
books@[EMAIL PROTECTED]   2008-04-24 06:28:18 
Re: BUG #4123: Statement.setQueryTimeout does not work with Post
valgog <valgog@[EMAIL   2008-04-25 09:59:54 
Re: BUG #4123: Statement.setQueryTimeout does not work
Kevin.Grittner@[EMAIL PRO  2008-04-25 16:38:08 
Re: BUG #4123: Statement.setQueryTimeout does not work with Post
valgog <valgog@[EMAIL   2008-04-27 23:07:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 10:30:20 CDT 2008.