Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query Timeout not working in jdbc template

4dbf52d7-2581-4c1d-8eaa-60a35bce2207Feb 11 2018 — edited Feb 12 2018

Hi Everyone,

Can any one help on this:

JDK: 1.8

JDBC

<artifactId>jdbc</artifactId>

        <version>5.5.30.Final</version>

I am trying to set limit to the execution of the query for 5 seconds.

I tried with the below code. I didnot work .

Expected :

When i run the query which take 5 second to execute. should close the process and throw the exception.

public NamedParameterJdbcTemplate getJdbcTemplate() {

if (null == jdbcTemplate) {

Properties test = new Properties();

test.setProperty(OracleConnection.CONNECTION_PROPERTY_THIN_READ_TIMEOUT, "5000");

JdbcTemplate temp1= null;

try {

testDataSource.setConnectionProperties(test);

temp1 = new JdbcTemplate(testDataSource);

temp1.setQueryTimeout(1);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

jdbcTemplate = new NamedParameterJdbcTemplate(temp1);

}

return jdbcTemplate;

}

Thanks,

Dimosh

Comments
Post Details
Added on Feb 11 2018
0 comments
4,025 views