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 km...@apache.org on 2007/09/17 19:53:12 UTC

svn commit: r576546 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ engine/org/apache/derby/impl/jdbc/ testing/org/apache/derbyTesting/functionTests/tests/jdbc4/

Author: kmarsden
Date: Mon Sep 17 10:53:11 2007
New Revision: 576546

URL: http://svn.apache.org/viewvc?rev=576546&view=rev
Log:
DERBY-3074 Database shutdown exception 08006 throws SQLTransientConnectionException instead of SQLNonTransientConnectionException

DERBY-3075 Client error: 08001 Error connecting to server.. throws SQLTransientConnectionException instead of SQLNonTransientConnectionException



Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory40.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestJDBC40Exception.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory40.java?rev=576546&r1=576545&r2=576546&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/SQLExceptionFactory40.java Mon Sep 17 10:53:11 2007
@@ -28,9 +28,10 @@
 import java.sql.SQLFeatureNotSupportedException;
 import java.sql.SQLIntegrityConstraintViolationException;
 import java.sql.SQLInvalidAuthorizationSpecException;
+import java.sql.SQLNonTransientConnectionException;
 import java.sql.SQLSyntaxErrorException;
 import java.sql.SQLTransactionRollbackException;
-import java.sql.SQLTransientConnectionException;
+
 
 /**
  * SQLException factory class to create jdbc 40 exception classes
@@ -65,8 +66,8 @@
         } else if (sqlState.startsWith(SQLState.CONNECTIVITY_PREFIX) ||
             errCode >= ExceptionSeverity.SESSION_SEVERITY) {
             //none of the sqlstate supported by derby belongs to
-            //NonTransientConnectionException
-            ex = new SQLTransientConnectionException(message, sqlState, errCode);
+            //TransientConnectionException. DERBY-3075
+            ex = new SQLNonTransientConnectionException(message, sqlState, errCode);
         } else if (sqlState.startsWith(SQLState.SQL_DATA_PREFIX)) {
             ex = new SQLDataException(message, sqlState, errCode);
         } else if (sqlState.startsWith(SQLState.INTEGRITY_VIOLATION_PREFIX)) {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java?rev=576546&r1=576545&r2=576546&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/SQLExceptionFactory40.java Mon Sep 17 10:53:11 2007
@@ -25,9 +25,9 @@
 import java.sql.SQLException;
 import java.sql.SQLIntegrityConstraintViolationException;
 import java.sql.SQLInvalidAuthorizationSpecException;
+import java.sql.SQLNonTransientConnectionException;
 import java.sql.SQLSyntaxErrorException;
 import java.sql.SQLTransactionRollbackException;
-import java.sql.SQLTransientConnectionException;
 import java.sql.SQLFeatureNotSupportedException;
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.shared.common.reference.SQLState;
@@ -43,7 +43,7 @@
      * overwrites super class method to create JDBC4 exceptions      
      * SQLSTATE CLASS (prefix)     Exception
      * 0A                          java.sql.SQLFeatureNotSupportedException
-     * 08                          java.sql.SQLTransientConnectionException
+     * 08                          java.sql.SQLNonTransientConnectionException
      * 22                          java.sql.SQLDataException
      * 28                          java.sql.SQLInvalidAuthorizationSpecException
      * 40                          java.sql.SQLTransactionRollbackException
@@ -72,8 +72,8 @@
         final SQLException ex;
         if (sqlState.startsWith(SQLState.CONNECTIVITY_PREFIX)) {
             //none of the sqlstate supported by derby belongs to
-            //NonTransientConnectionException
-            ex = new SQLTransientConnectionException(message, sqlState,
+            //TransientConnectionException DERBY-3074
+            ex = new SQLNonTransientConnectionException(message, sqlState,
                     severity, t);
         } else if (sqlState.startsWith(SQLState.SQL_DATA_PREFIX)) {
             ex = new SQLDataException(message, sqlState, severity, t);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestJDBC40Exception.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestJDBC40Exception.java?rev=576546&r1=576545&r2=576546&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestJDBC40Exception.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestJDBC40Exception.java Mon Sep 17 10:53:11 2007
@@ -23,16 +23,21 @@
 package org.apache.derbyTesting.functionTests.tests.jdbc4;
 
 import java.sql.Connection;
+import java.sql.SQLNonTransientConnectionException;
 import java.sql.Statement;
 import java.sql.SQLDataException;
 import java.sql.SQLException;
 import java.sql.SQLIntegrityConstraintViolationException;
 import java.sql.SQLSyntaxErrorException;
-import java.sql.SQLTransientConnectionException;
 import java.sql.SQLTransactionRollbackException;
+
+import javax.sql.DataSource;
+
 import junit.framework.Test;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.DatabasePropertyTestSetup;
+import org.apache.derbyTesting.junit.J2EEDataSource;
+import org.apache.derbyTesting.junit.JDBCDataSource;
 import org.apache.derbyTesting.junit.TestConfiguration;
 
 public class TestJDBC40Exception extends BaseJDBCTestCase {
@@ -93,10 +98,38 @@
         try {
             stmt.execute("select * from exception1");
             fail("Statement didn't fail.");
-        } catch (SQLTransientConnectionException cone) {
+        } catch (SQLNonTransientConnectionException cone) {
             assertTrue("Unexpected SQL State: " + cone.getSQLState(),
                        cone.getSQLState().startsWith("08"));
         }
+        
+        if (usingEmbedded())
+        {
+        	// test exception after database shutdown
+        	// DERBY-3074
+        	stmt = createStatement();
+        	TestConfiguration.getCurrent().shutdownDatabase();
+        	try {
+        		stmt.execute("select * from exception1");
+        		fail("Statement didn't fail.");
+        	} catch (SQLNonTransientConnectionException cone) {
+        		assertTrue("Unexpected SQL State: " + cone.getSQLState(),
+        				cone.getSQLState().startsWith("08"));        	  
+        	}
+        }
+        // test connection to server which is not up.
+        // DERBY-3075
+        if (usingDerbyNetClient()) {
+        	DataSource ds = JDBCDataSource.getDataSource();
+        	JDBCDataSource.setBeanProperty(ds, "portNumber", new Integer(0));
+        	try {
+        		ds.getConnection();
+        	} catch (SQLNonTransientConnectionException cone) {
+        		assertTrue("Unexpected SQL State: " + cone.getSQLState(),
+        				cone.getSQLState().startsWith("08"));   
+        	}
+        }
+
     }
     
     public void testSyntaxErrorException() throws SQLException {