dirkv 2003/08/26 07:16:33
Modified: dbcp/src/java/org/apache/commons/dbcp PoolingConnection.java
Log:
- do not throw NoSuchElementException (runtime) but SQLNestedException
- add todo
Revision Changes Path
1.9 +41 -2
jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/PoolingConnection.java
Index: PoolingConnection.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/PoolingConnection.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- PoolingConnection.java 22 Aug 2003 16:59:11 -0000 1.8
+++ PoolingConnection.java 26 Aug 2003 14:16:33 -0000 1.9
@@ -62,6 +62,8 @@
package org.apache.commons.dbcp;
import java.sql.*;
+import java.util.NoSuchElementException;
+
import org.apache.commons.pool.*;
/**
@@ -126,6 +128,8 @@
public synchronized PreparedStatement prepareStatement(String sql) throws
SQLException {
try {
return(PreparedStatement)(_pstmtPool.borrowObject(createKey(sql)));
+ } catch(NoSuchElementException e) {
+ throw new SQLNestedException("MaxOpenPreparedStatements limit reached",
e);
} catch(RuntimeException e) {
throw e;
} catch(Exception e) {
@@ -140,12 +144,47 @@
public synchronized PreparedStatement prepareStatement(String sql, int
resultSetType, int resultSetConcurrency) throws SQLException {
try {
return(PreparedStatement)(_pstmtPool.borrowObject(createKey(sql,resultSetType,resultSetConcurrency)));
+ } catch(NoSuchElementException e) {
+ throw new SQLNestedException("MaxOpenPreparedStatements limit reached",
e);
} catch(RuntimeException e) {
throw e;
} catch(Exception e) {
throw new SQLNestedException("Borrow prepareStatement from pool
failed", e);
}
}
+
+ // ------------------- JDBC 3.0 -----------------------------------------
+ // Will be commented by the build process on a JDBC 2.0 system
+
+/* JDBC_3_ANT_KEY_BEGIN */
+
+// TODO: possible enhancement, cache these preparedStatements as well
+
+// public PreparedStatement prepareStatement(String sql, int resultSetType,
+// int resultSetConcurrency,
+// int resultSetHoldability)
+// throws SQLException {
+// return super.prepareStatement(
+// sql, resultSetType, resultSetConcurrency, resultSetHoldability);
+// }
+//
+// public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
+// throws SQLException {
+// return super.prepareStatement(sql, autoGeneratedKeys);
+// }
+//
+// public PreparedStatement prepareStatement(String sql, int columnIndexes[])
+// throws SQLException {
+// return super.prepareStatement(sql, columnIndexes);
+// }
+//
+// public PreparedStatement prepareStatement(String sql, String columnNames[])
+// throws SQLException {
+// return super.prepareStatement(sql, columnNames);
+// }
+
+/* JDBC_3_ANT_KEY_END */
+
/**
* Create a PStmtKey for the given arguments.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]