The Spring Framework has two similar classes: JdbcTemplate is the old, Java 1.4 class, and SimpleJdbcTemplate is newer, with nicer methods.
JdbcTemplate has a method setQueryTimeout, which basically gives me access to a method with the same name on the underlying Statement object.
Is there any way to do something similar with a SimpleJdbcTemplate?
Solution: Based on skaffman's answer, I create the SimpleJdbcTemplate
object myself from a JdbcTemplate
, so now I can do whatever I want. Code:
JdbcTemplate jdbcTemplate = this.getJdbcTemplate();
jdbcTemplate.setQueryTimeout(30);
SimpleJdbcTemplate simpleJdbcTemplate = new SimpleJdbcTemplate(jdbcTemplate);
A bit of a mouthful, but gets the job done.
Update: This is indeed more complicated than necessary. See the answer.