commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r420357 - in /jakarta/commons/proper/dbcp/trunk: src/java/org/apache/commons/dbcp/ src/test/org/apache/commons/dbcp/ xdocs/
Date Sun, 09 Jul 2006 21:50:32 GMT
Author: psteitz
Date: Sun Jul  9 14:50:32 2006
New Revision: 420357

URL: http://svn.apache.org/viewvc?rev=420357&view=rev
Log:
Added connection info to SQLException messages when closed connections
(resp stmts) are accessed in DelegatingConnection, DelegatingStatement.
JIRA: DBCP-187
Reported (and patched) by Ralf Hauser

Modified:
    jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java
    jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingStatement.java
    jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestDelegatingConnection.java
    jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestDelegatingStatement.java
    jakarta/commons/proper/dbcp/trunk/xdocs/changes.xml

Modified: jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java?rev=420357&r1=420356&r2=420357&view=diff
==============================================================================
--- jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java
(original)
+++ jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingConnection.java
Sun Jul  9 14:50:32 2006
@@ -322,7 +322,8 @@
 
     protected void checkOpen() throws SQLException {
         if(_closed) {
-            throw new SQLException("Connection is closed.");
+            throw new SQLException
+                ("Connection " + _conn + " is closed.");
         }
     }
 

Modified: jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingStatement.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingStatement.java?rev=420357&r1=420356&r2=420357&view=diff
==============================================================================
--- jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingStatement.java
(original)
+++ jakarta/commons/proper/dbcp/trunk/src/java/org/apache/commons/dbcp/DelegatingStatement.java
Sun Jul  9 14:50:32 2006
@@ -133,7 +133,9 @@
 
     protected void checkOpen() throws SQLException {
         if(isClosed()) {
-            throw new SQLException(this.getClass().getName() + " is closed.");
+            throw new SQLException
+                (this.getClass().getName() + " with address: \"" + 
+                this.toString() + "\" is closed.");
         }
     }
 

Modified: jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestDelegatingConnection.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestDelegatingConnection.java?rev=420357&r1=420356&r2=420357&view=diff
==============================================================================
--- jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestDelegatingConnection.java
(original)
+++ jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestDelegatingConnection.java
Sun Jul  9 14:50:32 2006
@@ -17,6 +17,7 @@
 package org.apache.commons.dbcp;
 
 import java.sql.Connection;
+import java.sql.SQLException;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -76,5 +77,16 @@
         assertTrue(!conn.equals(null));
         assertTrue(conn.equals(conn2));
         assertTrue(!conn.equals(conn3));
+    }
+    
+    public void testCheckOpen() throws Exception {
+        conn.checkOpen();
+        conn.close();
+        try {
+            conn.checkOpen();
+            fail("Expecting SQLException");
+        } catch (SQLException ex) {
+            // expected
+        }      
     }
 }

Modified: jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestDelegatingStatement.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestDelegatingStatement.java?rev=420357&r1=420356&r2=420357&view=diff
==============================================================================
--- jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestDelegatingStatement.java
(original)
+++ jakarta/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestDelegatingStatement.java
Sun Jul  9 14:50:32 2006
@@ -17,6 +17,7 @@
 package org.apache.commons.dbcp;
 
 import java.sql.Connection;
+import java.sql.SQLException;
 import java.sql.Statement;
 
 import junit.framework.Test;
@@ -73,5 +74,16 @@
         assertTrue(!stmt.equals(null));
         assertTrue(stmt.equals(stmt2));
         assertTrue(!stmt.equals(stmt3));
+    }
+    
+    public void testCheckOpen() throws Exception {
+        stmt.checkOpen();
+        stmt.close();
+        try {
+            stmt.checkOpen();
+            fail("Expecting SQLException");
+        } catch (SQLException ex) {
+            // expected
+        }      
     }
 }

Modified: jakarta/commons/proper/dbcp/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/dbcp/trunk/xdocs/changes.xml?rev=420357&r1=420356&r2=420357&view=diff
==============================================================================
--- jakarta/commons/proper/dbcp/trunk/xdocs/changes.xml (original)
+++ jakarta/commons/proper/dbcp/trunk/xdocs/changes.xml Sun Jul  9 14:50:32 2006
@@ -60,6 +60,10 @@
         Modified activateObject in PoolableConnection to test connection
         properties before resetting to defaults.
       </action>
+      <action dev="psteitz" type="update" issue="DBCP-187" due-to="Ralf Hauser">
+        Added connection info to SQLException messages when closed connections
+        (resp stmts) are accessed in DelegatingConnection, DelegatingStatement.
+      </action>
     </release>   
   </body>
 </document>



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message