You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ma...@apache.org on 2013/02/07 17:42:55 UTC
svn commit: r1443599 -
/db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
Author: mamta
Date: Thu Feb 7 16:42:55 2013
New Revision: 1443599
URL: http://svn.apache.org/viewvc?rev=1443599&view=rev
Log:
DERBY-6053 (Client should use a prepared statement rather than regular statement for Connection.setTransactionIsolation)
Sinnce Connection object is already synchronized, no need to use synchronized Hashtable, instead us HashMap.
Also parameterize HashMap object declaration for easier usage and tighter type checking by the compiler.
Modified:
db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java?rev=1443599&r1=1443598&r2=1443599&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java Thu Feb 7 16:42:55 2013
@@ -23,6 +23,7 @@ package org.apache.derby.client.am;
import java.sql.SQLException;
import java.util.Collections;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
@@ -93,7 +94,9 @@ public abstract class Connection
//prepared statements associated with isolation level change are stored
// in isolationLevelPreparedStmts
- private Hashtable isolationLevelPreparedStmts = new Hashtable();
+ final private HashMap<String, PreparedStatement>
+ isolationLevelPreparedStmts =
+ new HashMap<String, PreparedStatement>();
// used to get transaction isolation level
private Statement getTransactionIsolationStmt = null;
@@ -792,22 +795,15 @@ public abstract class Connection
SQLException accumulatedExceptions = null;
//Close prepared statements associated with isolation level change
- if (isolationLevelPreparedStmts != null) {
- PreparedStatement ps;
- for (Iterator<PreparedStatement> it = isolationLevelPreparedStmts.keySet().iterator();
- it.hasNext(); ) {
- try {
- Object key = it.next();
- ps = (PreparedStatement)isolationLevelPreparedStmts.get(key);
- ps.close();
- ps = null;
- } catch (SQLException se) {
- accumulatedExceptions = Utils.accumulateSQLException(
- se, accumulatedExceptions);
- }
+ for (PreparedStatement ps : isolationLevelPreparedStmts.values() ) {
+ try {
+ ps.close();
+ } catch (SQLException se) {
+ accumulatedExceptions = Utils.accumulateSQLException(
+ se, accumulatedExceptions);
}
- isolationLevelPreparedStmts.clear();
}
+ isolationLevelPreparedStmts.clear();
if (getTransactionIsolationStmt != null) {
try {
getTransactionIsolationStmt.close();