JDBC Statement is not closed if exception appeared during query execution

Description

JDBC Statement is not closed when exception appeared during query execution, JPA native query on Oracle v11 database.

If run statement in cycle

On iteration 300 error appeared: ORA-01000: maximum open cursors exceeded

I can provide sample project if required,
but issue is obvious by code review, method "org.hibernate.loader.Loader.doQuery(SessionImplementor, QueryParameters, boolean, ResultTransformer)"
Exception appeared on line with "executeQueryStatement", this block is not covered by "finally".

org.hibernate.loader.Loader.doQuery(SessionImplementor, QueryParameters, boolean, ResultTransformer)

Also if enable logging, normal execution contains "JdbcCoordinatorImpl: Closing prepared statement", and absent in execution with exception.

iteration for normal query

iteration for query with exception

Solution: "executeQueryStatement" have to be covered with "finally".

Environment

Oracle 11

Assignee

Gail Badner

Reporter

Pavlo Z

Fix versions

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure