db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r595047 - in /db/derby/code/trunk/java: client/org/apache/derby/client/ client/org/apache/derby/client/am/ testing/org/apache/derbyTesting/functionTests/tests/derbynet/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ testing/or...
Date Wed, 14 Nov 2007 20:50:36 GMT
Author: mamta
Date: Wed Nov 14 12:50:34 2007
New Revision: 595047

URL: http://svn.apache.org/viewvc?rev=595047&view=rev
Log:
DERBY-3172

Change the Network Server code so that when the Network Server is shutdown, any api on Connection
object will 
raise a Connection error event (similar to what is done in embedded mode). This also required
me changing the
disconnectError from -4999 to 40000(to match embedded). This change was made client.am.SqlCode.
I have added tests
for all the apis on Connection object in DataSourceTest. Had to change couple tests which
were testing for
-4999. Now they look for 40000. I will merge this change into 10.3 and run tests there before
committing the changes
in 10.3 codeline.


Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlCode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java?rev=595047&r1=595046&r2=595047&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/ClientPooledConnection.java Wed
Nov 14 12:50:34 2007
@@ -23,8 +23,8 @@
 import java.sql.PreparedStatement;
 import java.sql.SQLException;
 import org.apache.derby.client.net.NetXAConnection;
+import org.apache.derby.iapi.error.ExceptionSeverity;
 import org.apache.derby.jdbc.ClientBaseDataSource;
-import org.apache.derby.jdbc.ClientDataSource;
 import org.apache.derby.jdbc.ClientDriver;
 import org.apache.derby.client.am.ClientMessageId;
 import org.apache.derby.client.am.SqlException;
@@ -263,6 +263,10 @@
 
     // Not public, but needs to be visible to am.LogicalConnection
     public void trashConnection(SqlException exception) {
+		// only report fatal error  
+		if (exception.getErrorCode() < ExceptionSeverity.SESSION_SEVERITY)
+			return;
+
         for (java.util.Enumeration e = listeners_.elements(); e.hasMoreElements();) {
             javax.sql.ConnectionEventListener listener = (javax.sql.ConnectionEventListener)
e.nextElement();
             java.sql.SQLException sqle = exception.getSQLException();

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java?rev=595047&r1=595046&r2=595047&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection.java Wed
Nov 14 12:50:34 2007
@@ -130,17 +130,42 @@
         }
     }
 
+    /**
+     * This method checks if the physcial connection underneath is null and
+     * if yes, then it simply returns.
+     * Otherwise, if the severity of exception is greater than equal to
+     * ExceptionSeverity.SESSION_SEVERITY, then we will send 
+     * connectionErrorOccurred event to all the registered listeners.
+     * 
+     * @param sqle SQLException An event will be sent to the listeners if the
+     * exception's severity is >= ExceptionSeverity.SESSION_SEVERITY.
+     */
+	final void notifyException(SQLException sqle) {
+        if (physicalConnection_ != null) 
+        	pooledConnection_.trashConnection(new SqlException(sqle));
+	}
+
     // ---------------------- wrapped public entry points ------------------------
     // All methods are forwarded to the physical connection in a standard way
 
     synchronized public java.sql.Statement createStatement() throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.createStatement();
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.createStatement();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     synchronized public java.sql.PreparedStatement prepareStatement(String sql) throws SQLException
{
-        checkForNullPhysicalConnection();
-        return physicalConnection_.prepareStatement(sql);
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.prepareStatement(sql);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     synchronized public PreparedStatement preparePositionedUpdateStatement(String sql, Section
querySection) throws SqlException {
@@ -153,177 +178,337 @@
     }
 
     synchronized public java.sql.CallableStatement prepareCall(String sql) throws SQLException
{
-        checkForNullPhysicalConnection();
-        return physicalConnection_.prepareCall(sql);
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.prepareCall(sql);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public String nativeSQL(String sql) throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.nativeSQL(sql);
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.nativeSQL(sql);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     synchronized public void setAutoCommit(boolean autoCommit) throws SQLException {
-        checkForNullPhysicalConnection();
-        physicalConnection_.setAutoCommit(autoCommit);
+		try {
+	        checkForNullPhysicalConnection();
+	        physicalConnection_.setAutoCommit(autoCommit);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public boolean getAutoCommit() throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.getAutoCommit();
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.getAutoCommit();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     synchronized public void commit() throws SQLException {
-        checkForNullPhysicalConnection();
-        physicalConnection_.commit();
+		try {
+	        checkForNullPhysicalConnection();
+	        physicalConnection_.commit();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     synchronized public void rollback() throws SQLException {
-        checkForNullPhysicalConnection();
-        physicalConnection_.rollback();
+		try {
+	        checkForNullPhysicalConnection();
+	        physicalConnection_.rollback();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     synchronized public void setTransactionIsolation(int level) throws SQLException {
-        checkForNullPhysicalConnection();
-        physicalConnection_.setTransactionIsolation(level);
+		try {
+	        checkForNullPhysicalConnection();
+	        physicalConnection_.setTransactionIsolation(level);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public int getTransactionIsolation() throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.getTransactionIsolation();
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.getTransactionIsolation();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public java.sql.SQLWarning getWarnings() throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.getWarnings();
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.getWarnings();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     synchronized public void clearWarnings() throws SQLException {
-        checkForNullPhysicalConnection();
-        physicalConnection_.clearWarnings();
+		try {
+	        checkForNullPhysicalConnection();
+	        physicalConnection_.clearWarnings();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public java.sql.DatabaseMetaData getMetaData() throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.getMetaData();
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.getMetaData();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     synchronized public void setReadOnly(boolean readOnly) throws SQLException {
-        checkForNullPhysicalConnection();
-        physicalConnection_.setReadOnly(readOnly);
+		try {
+	        checkForNullPhysicalConnection();
+	        physicalConnection_.setReadOnly(readOnly);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public boolean isReadOnly() throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.isReadOnly();
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.isReadOnly();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     synchronized public void setCatalog(String catalog) throws SQLException {
-        checkForNullPhysicalConnection();
-        physicalConnection_.setCatalog(catalog);
+		try {
+	        checkForNullPhysicalConnection();
+	        physicalConnection_.setCatalog(catalog);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public String getCatalog() throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.getCatalog();
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.getCatalog();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     synchronized public java.sql.Statement createStatement(int resultSetType,
                                                            int resultSetConcurrency) throws
SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.createStatement(resultSetType, resultSetConcurrency);
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.createStatement(resultSetType, resultSetConcurrency);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     synchronized public java.sql.PreparedStatement prepareStatement(String sql,
                                                                     int resultSetType,
                                                                     int resultSetConcurrency)
throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.prepareStatement(sql, resultSetType, resultSetConcurrency);
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.prepareStatement(sql, resultSetType, resultSetConcurrency);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     synchronized public java.sql.CallableStatement prepareCall(String sql,
                                                                int resultSetType,
                                                                int resultSetConcurrency)
throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.prepareCall(sql, resultSetType, resultSetConcurrency);
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.prepareCall(sql, resultSetType, resultSetConcurrency);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public java.util.Map getTypeMap() throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.getTypeMap();
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.getTypeMap();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     synchronized public void setTypeMap(java.util.Map map) throws SQLException {
-        checkForNullPhysicalConnection();
-        physicalConnection_.setTypeMap(map);
+		try {
+	        checkForNullPhysicalConnection();
+	        physicalConnection_.setTypeMap(map);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency,
                                               int resultSetHoldability) throws SQLException
{
-        checkForNullPhysicalConnection();
-        return physicalConnection_.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.createStatement(resultSetType, resultSetConcurrency,
resultSetHoldability);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public java.sql.CallableStatement prepareCall(String sql, int resultSetType,
                                                   int resultSetConcurrency,
                                                   int resultSetHoldability) throws SQLException
{
-        checkForNullPhysicalConnection();
-        return physicalConnection_.prepareCall(sql, resultSetType, resultSetConcurrency,
resultSetHoldability);
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.prepareCall(sql, resultSetType, resultSetConcurrency,
resultSetHoldability);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public java.sql.PreparedStatement prepareStatement(String sql, int resultSetType,
                                                        int resultSetConcurrency, int resultSetHoldability)
             throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.prepareStatement(sql, resultSetType, resultSetConcurrency,
-                resultSetHoldability);
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.prepareStatement(sql, resultSetType, resultSetConcurrency,
+	                resultSetHoldability);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public java.sql.PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
             throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.prepareStatement(sql, autoGeneratedKeys);
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.prepareStatement(sql, autoGeneratedKeys);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public java.sql.PreparedStatement prepareStatement(String sql, int columnIndexes[])
             throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.prepareStatement(sql, columnIndexes);
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.prepareStatement(sql, columnIndexes);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public java.sql.PreparedStatement prepareStatement(String sql, String columnNames[])
             throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.prepareStatement(sql, columnNames);
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.prepareStatement(sql, columnNames);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public void setHoldability(int holdability) throws SQLException {
-        checkForNullPhysicalConnection();
-        physicalConnection_.setHoldability(holdability);
+		try {
+	        checkForNullPhysicalConnection();
+	        physicalConnection_.setHoldability(holdability);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public int getHoldability() throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.getHoldability();
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.getHoldability();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public java.sql.Savepoint setSavepoint() throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.setSavepoint();
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.setSavepoint();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public java.sql.Savepoint setSavepoint(String name) throws SQLException {
-        checkForNullPhysicalConnection();
-        return physicalConnection_.setSavepoint(name);
+		try {
+	        checkForNullPhysicalConnection();
+	        return physicalConnection_.setSavepoint(name);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public void rollback(java.sql.Savepoint savepoint) throws SQLException {
-        checkForNullPhysicalConnection();
-        physicalConnection_.rollback(savepoint);
+		try {
+	        checkForNullPhysicalConnection();
+	        physicalConnection_.rollback(savepoint);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     public void releaseSavepoint(java.sql.Savepoint savepoint) throws SQLException {
-        checkForNullPhysicalConnection();
-        physicalConnection_.releaseSavepoint(savepoint);
+		try {
+	        checkForNullPhysicalConnection();
+	        physicalConnection_.releaseSavepoint(savepoint);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
 
     //----------------------------------------------------------------------------

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlCode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlCode.java?rev=595047&r1=595046&r2=595047&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlCode.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/SqlCode.java Wed Nov 14 12:50:34
2007
@@ -50,7 +50,7 @@
 
     public final static SqlCode queuedXAError = new SqlCode(-4203);
 
-    public final static SqlCode disconnectError = new SqlCode(-4499);
+    public final static SqlCode disconnectError = new SqlCode(40000);
 
     public final static SqlCode undefinedError = new SqlCode(-99999);
     

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java?rev=595047&r1=595046&r2=595047&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/derbynet/BadConnectionTest.java
Wed Nov 14 12:50:34 2007
@@ -65,7 +65,7 @@
 					"jdbc:derby://" + host + ":" + port + "/testbase");
 		} catch (SQLException e) {
 			assertSQLState("08004", e);
-			assertEquals(-4499, e.getErrorCode());
+			assertEquals(40000, e.getErrorCode());
 		}
 	}
 	
@@ -84,7 +84,7 @@
 		} catch (SQLException e)
 		{
 			assertSQLState("08004", e);
-			assertEquals(-4499, e.getErrorCode());
+			assertEquals(40000, e.getErrorCode());
 		}
 	}
 	

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java?rev=595047&r1=595046&r2=595047&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
Wed Nov 14 12:50:34 2007
@@ -32,6 +32,7 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.sql.Savepoint;
 import java.util.Hashtable;
 import java.util.Iterator;
 
@@ -192,6 +193,360 @@
     }
      */
     
+    /**
+     * Test case for DERBY-3172
+     * When the Derby engine is shutdown or Network Server is brought down, any
+     * api on JDBC Connection object should generate a Connection error event.
+     */
+    public void testConnectionErrorEvent() throws SQLException, Exception
+    {
+    	Connection conn;
+    	ConnectionPoolDataSource ds;
+    	PooledConnection pc;
+    	Statement st;
+        AssertEventCatcher aes12 = new AssertEventCatcher(12);
+        //Get the correct ConnectionPoolDataSource object
+        if (usingEmbedded())
+        {
+        	ds = new EmbeddedConnectionPoolDataSource();
+            ((EmbeddedConnectionPoolDataSource)ds).setDatabaseName(dbName);
+        } else
+        {
+            ds = new ClientConnectionPoolDataSource();
+            ((ClientConnectionPoolDataSource)ds).setDatabaseName(dbName);
+        }
+        pc = ds.getPooledConnection();
+        //Add a connection event listener to ConnectionPoolDataSource
+        pc.addConnectionEventListener(aes12);
+        conn = pc.getConnection();
+        st = conn.createStatement();
+        //TAB1 does not exist and hence catch the expected exception
+        try {
+            st.executeUpdate("drop table TAB1");
+        } catch (SQLException sqle) {
+            assertSQLState("42Y55", sqle);
+        }
+        //No event should have been generated at this point
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertFalse(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        //Shutdown the Derby engine or Network Server depending on what 
+        //mode we are running in.
+        if (usingEmbedded())
+        {
+        	getTestConfiguration().shutdownDatabase();
+        } else
+        {
+        	getTestConfiguration().stopNetworkServer();
+        }
+        //Now try to use various apis on the JDBC Connection object created 
+        //before shutdown and they all should generate connection error event.
+        try {
+            conn.prepareStatement("CREATE TABLE TAB1(COL1 INT NOT NULL)");
+        } catch (SQLException e) {
+            //The first call on JDBC Connection object after Network Server
+            //shutdown will generate a communication error and that's why we
+            //are checking for SQL State 08006 rather than No current connection
+            //SQL State 08003. In embedded mode, we will get SQL State 08003
+        	//meaning No current connection
+            if (usingEmbedded())
+                assertSQLState("08003", e);
+            else
+                assertSQLState("08006", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.prepareStatement("CREATE TABLE TAB1(COL1 INT NOT NULL)", 1);
+        } catch (SQLException e) {
+            assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+        	int[] columnIndexes = {1};
+            conn.prepareStatement("CREATE TABLE TAB1(COL1 INT NOT NULL)", 
+            		columnIndexes);
+        } catch (SQLException e) {
+            assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+        	String[] columnNames = {"col1"};
+            conn.prepareStatement("CREATE TABLE TAB1(COL1 INT NOT NULL)", 
+            		columnNames);
+        } catch (SQLException e) {
+            assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.prepareStatement("CREATE TABLE TAB1(COL1 INT NOT NULL)",
+            		ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.prepareStatement("CREATE TABLE TAB1(COL1 INT NOT NULL)",
+            		ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
+            		ResultSet.CLOSE_CURSORS_AT_COMMIT);
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.createStatement();
+        } catch (SQLException e) {
+            assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, 
+            		ResultSet.CONCUR_READ_ONLY,
+            		ResultSet.CLOSE_CURSORS_AT_COMMIT);
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, 
+            ResultSet.CONCUR_READ_ONLY);
+        } catch (SQLException e) {
+            assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.prepareCall("CREATE TABLE TAB1(COL1 INT NOT NULL)",
+            		ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.prepareCall("CREATE TABLE TAB1(COL1 INT NOT NULL)");
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.prepareCall("CREATE TABLE TAB1(COL1 INT NOT NULL)",
+            		ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY,
+            		ResultSet.CLOSE_CURSORS_AT_COMMIT);
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.nativeSQL("CREATE TABLE TAB1(COL1 INT NOT NULL)");
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.getAutoCommit();
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.setAutoCommit(false);
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.getHoldability();
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.setHoldability(1);
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.commit();
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.rollback();
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.setSavepoint();
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.setSavepoint("savept1");
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.rollback((Savepoint)null);
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.releaseSavepoint((Savepoint)null);
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.getTransactionIsolation();
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.getWarnings();
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.clearWarnings();
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.getMetaData();
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.isReadOnly();
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.setReadOnly(true);
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.setCatalog(null);
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.getCatalog();
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.getTypeMap();
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        try {
+            conn.setTypeMap(null);
+        } catch (SQLException e) {
+                assertSQLState("08003", e);
+        }
+        assertFalse(aes12.didConnectionClosedEventHappen());
+        assertTrue(aes12.didConnectionErrorEventHappen());
+        aes12.resetState();
+        if (usingEmbedded())
+        {
+            Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
+        }else
+        {
+        	getTestConfiguration().startNetworkServer();
+        }
+
+        // Get a new connection to the database
+        conn = getConnection();
+        conn.close();
+    }
+    
     public void testAllDataSources() throws SQLException, Exception
     {
         Connection dmc = getConnection();
@@ -3277,19 +3632,11 @@
     // ConnectionEventListener methods
     public void connectionClosed(ConnectionEvent event)
     {
-        SQLException sqle = event.getSQLException();
-        if (sqle != null)
-            System.out.print("DataSourceTest-" + catcher + "; SQLSTATE="
-                + sqle.getSQLState());
         gotConnectionClosed = true;
     }
 
     public void connectionErrorOccurred(ConnectionEvent event)
     {
-        SQLException sqle = event.getSQLException();
-        if (sqle != null)
-            System.out.print("DataSourceTest-" + catcher + "; SQLSTATE=" +
-                sqle.getSQLState());
         gotConnectionErrorOccured = true;
     }
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTest.java?rev=595047&r1=595046&r2=595047&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/system/nstest/NsTest.java Wed
Nov 14 12:50:34 2007
@@ -310,7 +310,7 @@
 
 			System.out.println("\n\n " + sqe + sqe.getErrorCode() + " "
 					+ sqe.getSQLState());
-			if ((sqe.getErrorCode() == -4499)
+			if ((sqe.getErrorCode() == 40000)
 					|| sqe.getSQLState().equalsIgnoreCase("08001")) {
 				System.out
 				.println("\n Unable to connect, test cannot proceed. Please verify if the Network Server
is started on port 1900.");



Mime
View raw message