commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1148528 - /commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
Date Tue, 19 Jul 2011 21:01:16 GMT
Author: markt
Date: Tue Jul 19 21:01:15 2011
New Revision: 1148528

URL: http://svn.apache.org/viewvc?rev=1148528&view=rev
Log:
Generics

Modified:
    commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java

Modified: commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java?rev=1148528&r1=1148527&r2=1148528&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
Tue Jul 19 21:01:15 2011
@@ -22,7 +22,6 @@ import java.sql.Statement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.Collection;
-import java.util.Iterator;
 import org.apache.commons.pool2.KeyedObjectPool;
 import org.apache.commons.pool2.PoolableObjectFactory;
 import org.apache.commons.pool2.ObjectPool;
@@ -89,7 +88,8 @@ public class PoolableConnectionFactory
      * @param connectionInitSqls SQL statement to initialize {@link Connection}s.
      * @since 1.3
      */
-    synchronized public void setConnectionInitSql(Collection connectionInitSqls) {
+    synchronized public void setConnectionInitSql(
+            Collection<String> connectionInitSqls) {
         _connectionInitSqls = connectionInitSqls;
     }
 
@@ -189,7 +189,7 @@ public class PoolableConnectionFactory
     }
 
     protected void initializeConnection(Connection conn) throws SQLException {
-        Collection sqls = _connectionInitSqls;
+        Collection<String> sqls = _connectionInitSqls;
         if(conn.isClosed()) {
             throw new SQLException("initializeConnection: connection closed");
         }
@@ -197,14 +197,11 @@ public class PoolableConnectionFactory
             Statement stmt = null;
             try {
                 stmt = conn.createStatement();
-                for (Iterator iterator = sqls.iterator(); iterator.hasNext();)
-                {
-                    Object o = iterator.next();
-                    if (o == null) {
-                        throw new NullPointerException("null connectionInitSqls element");
+                for (String sql : sqls) {
+                    if (sql == null) {
+                        throw new NullPointerException(
+                                "null connectionInitSqls element");
                     }
-                    // o might not be a String instance
-                    String sql = o.toString();
                     stmt.execute(sql);
                 }
             } finally {
@@ -314,7 +311,7 @@ public class PoolableConnectionFactory
     protected volatile ConnectionFactory _connFactory = null;
     protected volatile String _validationQuery = null;
     protected volatile int _validationQueryTimeout = -1;
-    protected Collection _connectionInitSqls = null;
+    protected Collection<String> _connectionInitSqls = null;
     protected volatile ObjectPool<Connection> _pool = null;
     protected Boolean _defaultReadOnly = null;
     protected boolean _defaultAutoCommit = true;



Mime
View raw message