Skip to content

Per-Statement QueryTimeout for JdbcTemplate #26326

@MahatmaFatalError

Description

@MahatmaFatalError

Context:
As described here (#7444) it is possible to set a general query timeout for JdbcTemplate. However, having in mind that JdbcTemplate typically is a singleton bean, this is not sufficient when it comes to thread-per-request handling. Setting the queryTimeout state once would affect every subsequent query and interfere with parallel threads that use the JdbcTemplate bean.
The use case is to easily set statement timeout individually and dynamically (e.g. because of expected query runtime that is affected by different statement params).

Proposal for new feature:
Overloading once more the execute(), query(), queryForX() and update() methods by adding a timeout parameter that then gets passed though the stack (i.a.applyStatementSettings()) to finally call setQueryTimeout on the Statement.

Further References:
https://jira.spring.io/browse/DATAJDBC-638

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: dataIssues in data modules (jdbc, orm, oxm, tx)status: declinedA suggestion or change that we don't feel we should currently apply

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions