Author: tfischer
Date: Fri May 11 02:43:36 2012
New Revision: 1337010
URL: http://svn.apache.org/viewvc?rev=1337010&view=rev
Log:
improve statement/result set closing
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java?rev=1337010&r1=1337009&r2=1337010&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
(original)
+++
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
Fri May 11 02:43:36 2012
@@ -22,6 +22,7 @@ package org.apache.torque.oid;
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.ResultSet;
+import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Hashtable;
@@ -850,12 +851,14 @@ public class IDBroker implements Runnabl
.append('\'');
Statement statement = null;
+ ResultSet rs = null;
BigDecimal[] results = new BigDecimal[2];
+
try
{
statement = con.createStatement();
- ResultSet rs = statement.executeQuery(stmt.toString());
+ rs = statement.executeQuery(stmt.toString());
if (rs.next())
{
@@ -870,12 +873,35 @@ public class IDBroker implements Runnabl
throw new TorqueException("The table " + tableName
+ " does not have a proper entry in the " + ID_TABLE);
}
+ rs.close();
+ rs = null;
+ statement.close();
+ statement = null;
+
}
finally
{
+ if (rs != null)
+ {
+ try
+ {
+ rs.close();
+ }
+ catch (SQLException e)
+ {
+ log.warn("Could not close result set", e);
+ }
+ }
if (statement != null)
{
- statement.close();
+ try
+ {
+ statement.close();
+ }
+ catch (SQLException e)
+ {
+ log.warn("Could not close statement", e);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]