How to Set a Jdbc Timeout for a Single Query

Can I set a JDBC timeout for a single query?

If you are using spring to manage transactions a time out can be specified at the transaction level as well. @Transactional(timeout=10)

Is there any way to set jdbc query timeout globally in java project

You can use CONNECTION_PROPERTY_THIN_READ_TIMEOUT for Oracle thin driver. Add to datasource as follows

properties.put(OracleConnection.CONNECTION_PROPERTY_THIN_READ_TIMEOUT, readTimeoutMillis.toString());
dataSource.setConnectionProperties(properties);

How to set query timeout on PreparedStatement?

Im a fool, I figured this out yesterday and just forgot...

To solve it, do

preparedstatement = con.prepareStatement(query);
preparedstatement.setQueryTimeout(seconds);

and then just catch the exception.

How to set query timeout using string-keyed-jdbc-store cache

this is not currently possible. I've created https://issues.redhat.com/browse/ISPN-12825 and a pull request. It should be available in Infinispan 12.1.

How can i set timeout for SQLQuery?

My problem was in using old version of query-sql.
In latest releases timeout can be set like this:

  SQLQuery<Tuple> select = queryFactory.select(map.all());
select.setStatementOptions(StatementOptions.builder().setQueryTimeout(queryTimeout).build());


Related Topics



Leave a reply



Submit