[hibernate-issues] [Hibernate-JIRA] Issue Comment Edited: (HHH-2455) "Could not close a JDBC result set" output very often
Harald Gliebe (JIRA)
noreply at atlassian.com
Fri May 20 11:02:24 EDT 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-2455?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42365#action_42365 ]
Harald Gliebe edited comment on HHH-2455 at 5/20/11 10:00 AM:
--------------------------------------------------------------
This problem still exists in 3.6.4. Here is the patch. Please apply!
{noformat}
diff -u hibernate-core\src\main\java\org\hibernate\type\DbTimestampType.java DbTimestampType.java
--- hibernate-core\src\main\java\org\hibernate\type\DbTimestampType.java 2011-05-04 14:44:42.000000000 +0200
+++ d:\home\Downloads\DbTimestampType.java 2011-05-20 16:11:20.754870600 +0200
@@ -89,9 +89,10 @@
private Timestamp usePreparedStatement(String timestampSelectString, SessionImplementor session) {
PreparedStatement ps = null;
+ ResultSet rs = null;
try {
ps = session.getBatcher().prepareStatement( timestampSelectString );
- ResultSet rs = session.getBatcher().getResultSet( ps );
+ rs = session.getBatcher().getResultSet( ps );
rs.next();
Timestamp ts = rs.getTimestamp( 1 );
if ( log.isTraceEnabled() ) {
@@ -114,7 +115,7 @@
finally {
if ( ps != null ) {
try {
- session.getBatcher().closeStatement( ps );
+ session.getBatcher().closeQueryStatement( ps, rs );
}
catch( SQLException sqle ) {
log.warn( "unable to clean up prepared statement", sqle );
{noformat}
was (Author: hgliebe):
This problem still exists in 3.6.4. Here is the patch. Please apply!
diff -u hibernate-core\src\main\java\org\hibernate\type\DbTimestampType.java DbTimestampType.java
--- hibernate-core\src\main\java\org\hibernate\type\DbTimestampType.java 2011-05-04 14:44:42.000000000 +0200
+++ d:\home\Downloads\DbTimestampType.java 2011-05-20 16:11:20.754870600 +0200
@@ -89,9 +89,10 @@
private Timestamp usePreparedStatement(String timestampSelectString, SessionImplementor session) {
PreparedStatement ps = null;
+ ResultSet rs = null;
try {
ps = session.getBatcher().prepareStatement( timestampSelectString );
- ResultSet rs = session.getBatcher().getResultSet( ps );
+ rs = session.getBatcher().getResultSet( ps );
rs.next();
Timestamp ts = rs.getTimestamp( 1 );
if ( log.isTraceEnabled() ) {
@@ -114,7 +115,7 @@
finally {
if ( ps != null ) {
try {
- session.getBatcher().closeStatement( ps );
+ session.getBatcher().closeQueryStatement( ps, rs );
}
catch( SQLException sqle ) {
log.warn( "unable to clean up prepared statement", sqle );
> "Could not close a JDBC result set" output very often
> -----------------------------------------------------
>
> Key: HHH-2455
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2455
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.2.2
> Reporter: Dirk Feufel
> Priority: Minor
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> If you call this type of code (like the DbTimestampType class does), the AbstractBatcher outputs a warning "Could not close a JDBC result set".
> The problem should be that closing the prepared statement internally also closes the associated result sets and the AbstractBatcher still has a reference to this result set.
> One possible solution might be to provide an additional method
> public void closeStatement(PreparedStatement ps, ResultSet rs);
> (as already present for closeQueryStatement) in the AbstractBatcher allowing to close both in the right order.
> PreparedStatement ps = null;
> try {
> ps = session.getBatcher().prepareStatement( timestampSelectString );
> ResultSet rs = session.getBatcher().getResultSet( ps );
> ....
> } finally {
> if ( ps != null ) {
> session.getBatcher().closeStatement( ps );
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list