You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2013/07/24 01:16:00 UTC
svn commit: r1506365 -
/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
Author: markt
Date: Tue Jul 23 23:16:00 2013
New Revision: 1506365
URL: http://svn.apache.org/r1506365
Log:
Fix a couple of Eclipse warnings.
Take advantage of some Java 7 features.
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=1506365&r1=1506364&r2=1506365&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 23 23:16:00 2013
@@ -67,7 +67,7 @@ public class PoolableConnectionFactory
public void setValidationQuery(String validationQuery) {
_validationQuery = validationQuery;
}
-
+
/**
* Sets the validation query timeout, the amount of time, in seconds, that
* connection validation will wait for a response from the database when
@@ -186,7 +186,7 @@ public class PoolableConnectionFactory
config.setMaxIdlePerKey(1);
config.setMaxTotal(maxOpenPreparedStatements);
KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> stmtPool =
- new GenericKeyedObjectPool<PStmtKey,DelegatingPreparedStatement>((PoolingConnection)conn, config);
+ new GenericKeyedObjectPool<>((PoolingConnection)conn, config);
((PoolingConnection)conn).setStatementPool(stmtPool);
((PoolingConnection) conn).setCacheState(_cacheState);
}
@@ -199,9 +199,7 @@ public class PoolableConnectionFactory
throw new SQLException("initializeConnection: connection closed");
}
if(null != sqls) {
- Statement stmt = null;
- try {
- stmt = conn.createStatement();
+ try (Statement stmt = conn.createStatement();) {
for (String sql : sqls) {
if (sql == null) {
throw new NullPointerException(
@@ -209,14 +207,6 @@ public class PoolableConnectionFactory
}
stmt.execute(sql);
}
- } finally {
- if (stmt != null) {
- try {
- stmt.close();
- } catch(Exception t) {
- // ignored
- }
- }
}
}
}
@@ -292,12 +282,12 @@ public class PoolableConnectionFactory
if (conn.getAutoCommit() != _defaultAutoCommit) {
conn.setAutoCommit(_defaultAutoCommit);
}
- if ((_defaultTransactionIsolation != UNKNOWN_TRANSACTIONISOLATION)
- && (conn.getTransactionIsolation() !=
+ if ((_defaultTransactionIsolation != UNKNOWN_TRANSACTIONISOLATION)
+ && (conn.getTransactionIsolation() !=
_defaultTransactionIsolation)) {
conn.setTransactionIsolation(_defaultTransactionIsolation);
}
- if ((_defaultReadOnly != null) &&
+ if ((_defaultReadOnly != null) &&
(conn.isReadOnly() != _defaultReadOnly.booleanValue())) {
conn.setReadOnly(_defaultReadOnly.booleanValue());
}