-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Vasily,

On 7/21/14, 11:05 AM, Vasily Kukhta wrote:
> Oracle database. It is very important to ensure my app to have very
> small DB query timeouts (no longer than 3 seconds) to prevent
> long-running queries or database slowness from blocking all my
> application. To simulate long-running queries I have put the DB in
> QUIESCE state using ALTER SYSTEM QUIESCE RESTRICTED statement.

It's important to note that nothing in the JDBC driver will prevent a
/series/ of queries from taking more than 3 seconds. For example:

> String connprops = 
> "oracle.net.CONNECT_TIMEOUT=3000;oracle.jdbc.ReadTimeout=3000;" +
> "oracle.net.READ_TIMEOUT=3000";
> 
> pp.setMaxWait(2000);
> 
> pp.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.QueryTimeoutInterceptor(queryTimeout=3)");

With
> 
the above settings, issuing 10 queries can take up to 35 seconds:
up to 2 seconds to wait for a connection from the pool, up to 3
seconds to (re)connect to the database, then up to 3 seconds for each
of the 10 queries.

If you want to make sure that entire HTTP transactions don't take "too
long" then you'll have to keep track of the overall timeout yourself.

> That's how i work with connections (pretty simple):
> 
> Connection conn = dataSource.getConnection(); Statement stmt =
> null; ResultSet rs = null;
> 
> try { stmt = conn.createStatement();
> 
> rs = stmt.executeQuery(/*some select query*/);
> 
> 
> if (rs.next()) {
> 
> result = rs.getInt(1);
> 
> /*process the result*/
> 
> }
> 
> rs.close(); stmt.close(); conn.close();
> 
> } catch(Exception e) { logger.error("Exception: " + e.getMessage(),
> e); }finally { if (conn != null) {
> 
> if(rs!=null) rs.close(); if(stmt!=null) stmt.close(); 
> conn.close();
> 
> } }
> 
> Any ideas?

What query are you executing that should take longer than 3 seconds,
and therefore trigger the timeout?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJTzVswAAoJEBzwKT+lPKRY8m8P/3bh/pKfuS1oSodKgpyQFIvz
3OXlaSLK5QZBLsL9EFJJDw6bpNPKYHd3GdpQRmGqJYtG98qoXBVztZJPckPZBQwH
6mWuMAdbhwYZFNJVoyG72EfcZAamv+z8n4+WMTR6kjD6XbmAjAQMhgItOEMMnfSR
xyhb+w/dbwFk33Qrwf8Jfhj9/LHNBg99AS0SY8EgKGUT4PQZJ0DR2jY90oVWTy/k
ZaHXQxjNM1eiZPXTZmprsq+NVaLegG6BrJy0kTWgPrDk3jilgMgoFWDHb4MNuGCR
iSuWd8i+Sy6Y5VgYQBF5+UQylys7an3rZmYNRCr0GNj4NK2o9ipkvhTvaoH79G/z
26kungun8AEsmbBnK/YqzVYRxH66Ysy2mudGJYuDvNo55vJ7NoMtNt3Is0tF3Tgk
A/QjG3p4qPFMLeOMhlBqUvSAjsYIWsSBy9/698nkgDvILXKB4yMhyn+/jtoWImvy
EkHIlrKPAtGkMoRPqIODisTCDyVXd2bBntUM6rWfB7LrI8Hp8PLIN3d3IDXl3Mzc
qlTQiL0z5q9oOgxpaIXccWvR0kY7gobipASjyNfi09BGXAvM7rigFIHj9BO28x46
38r6vV2Ok7tatDJM7C2Xxoec69ke7CgQx3KEaabbCNzv3jFBbhfxULBPVtSoqzkY
XuqS6VKmEWnYoHbwbfkv
=f7nf
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to