db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1063822 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ client/org/apache/derby/client/net/ engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/impl/jdbc/ testing/org/apache/derbyTesting/functionTests/tests/jdbc4/
Date Wed, 26 Jan 2011 18:42:39 GMT
Author: rhillegas
Date: Wed Jan 26 18:42:38 2011
New Revision: 1063822

URL: http://svn.apache.org/viewvc?rev=1063822&view=rev
Log:
DERBY-4869: Add exception-raising stubs for Connection.get/setNetworkTimeout(), new methods
introduced by JDBC 4.1.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java
    db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionMethodsTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java?rev=1063822&r1=1063821&r2=1063822&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java Wed
Jan 26 18:42:38 2011
@@ -319,10 +319,40 @@ public class LogicalConnection40
     
     public  void    abort( Executor executor )  throws SQLException
     {
-        if ( physicalConnection_ != null )
+        try
         {
-            ((NetConnection40) physicalConnection_).abort( executor );
-        }
+            if ( physicalConnection_ != null )
+            {
+                ((NetConnection40) physicalConnection_).abort( executor );
+            }
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
+    }
+
+    public int getNetworkTimeout() throws SQLException
+    {
+        try
+        {
+    		checkForNullPhysicalConnection();
+            return ((NetConnection40) physicalConnection_).getNetworkTimeout();
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
+    }
+    
+    public void setNetworkTimeout( Executor executor, int milliseconds ) throws SQLException
+    {
+        try
+        {
+    		checkForNullPhysicalConnection();
+            ((NetConnection40) physicalConnection_).setNetworkTimeout( executor, milliseconds
);
+		} catch (SQLException sqle) {
+			notifyException(sqle);
+			throw sqle;
+		}
     }
     
 } // End class LogicalConnection40

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java?rev=1063822&r1=1063821&r2=1063822&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetConnection40.java Wed Jan
26 18:42:38 2011
@@ -451,4 +451,36 @@ public class  NetConnection40 extends or
              );
     }
 
+    public int getNetworkTimeout() throws SQLException
+    {
+        try
+        {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry(this, "getNetworkTimeout");
+            }
+            checkForClosedConnection();
+        }
+        catch ( SqlException se )
+        {
+            throw se.getSQLException();
+        }
+        throw SQLExceptionFactory.notImplemented ("getNetworkTimeout");
+    }
+    
+    public void setNetworkTimeout( Executor executor, int milliseconds ) throws SQLException
+    {
+        try
+        {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry(this, "setNetworkTimeout");
+            }
+            checkForClosedConnection();
+        }
+        catch ( SqlException se )
+        {
+            throw se.getSQLException();
+        }
+        throw SQLExceptionFactory.notImplemented ("setNetworkTimeout");
+    }
+
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java?rev=1063822&r1=1063821&r2=1063822&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredConnection40.java Wed
Jan 26 18:42:38 2011
@@ -360,4 +360,24 @@ public class BrokeredConnection40 extend
         }
     }
     
+    public int getNetworkTimeout() throws SQLException
+    {
+         try {
+             return ((EmbedConnection40) getRealConnection()).getNetworkTimeout();
+         } catch (SQLException sqle) {
+             notifyException(sqle);
+             throw sqle;
+         }
+    }
+    
+    public void setNetworkTimeout( Executor executor, int milliseconds ) throws SQLException
+    {
+         try {
+             ((EmbedConnection40) getRealConnection()).setNetworkTimeout( executor, milliseconds
);
+         } catch (SQLException sqle) {
+             notifyException(sqle);
+             throw sqle;
+         }
+    }
+
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java?rev=1063822&r1=1063821&r2=1063822&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnection40.java Wed
Jan 26 18:42:38 2011
@@ -318,4 +318,16 @@ public class EmbedConnection40 extends E
              );
     }
     
+    public int getNetworkTimeout() throws SQLException
+    {
+        checkIfClosed();
+        throw Util.notImplemented();
+    }
+    
+    public void setNetworkTimeout( Executor executor, int milliseconds ) throws SQLException
+    {
+        checkIfClosed();
+        throw Util.notImplemented();
+    }
+    
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionMethodsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionMethodsTest.java?rev=1063822&r1=1063821&r2=1063822&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionMethodsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ConnectionMethodsTest.java
Wed Jan 26 18:42:38 2011
@@ -40,6 +40,7 @@ import java.sql.Statement;
 import java.sql.SQLException;
 import java.sql.Blob;
 import java.sql.Clob;
+import java.sql.SQLFeatureNotSupportedException;
 import javax.sql.ConnectionPoolDataSource;
 import javax.sql.DataSource;
 import javax.sql.PooledConnection;
@@ -614,4 +615,53 @@ public class ConnectionMethodsTest exten
 
     }
     
+    /**
+     * Test the JDBC 4.1 Connection.getNetworkTimeout() and setNetworkTimeout() methods.
+     */
+    public void testGetSetNetworkTimeout() throws Exception
+    {
+        Connection  conn = getConnection();
+        println( "Testing get/setNetoworkTimeout() on a " + conn.getClass().getName() );
+        Wrapper41Conn   wrapper = new Wrapper41Conn( conn );
+
+        try {
+            wrapper.getNetworkTimeout();
+            fail( "Should raise an Unimplemented Feature exception." );
+        }
+        catch (SQLException se)
+        {
+            assertEquals( SQLFeatureNotSupportedException.class.getName(), se.getClass().getName()
);
+        }
+
+        try {
+            wrapper.setNetworkTimeout( null, 3 );
+            fail( "Should raise an Unimplemented Feature exception." );
+        }
+        catch (SQLException se)
+        {
+            assertEquals( SQLFeatureNotSupportedException.class.getName(), se.getClass().getName()
);
+        }
+
+        // now close the connection
+        conn.close();
+        
+        try {
+            wrapper.getNetworkTimeout();
+            fail( "Should object that the connection is closed." );
+        }
+        catch (SQLException se)
+        {
+            assertSQLState( CLOSED_CONNECTION, se );
+        }
+        
+        try {
+            wrapper.setNetworkTimeout( null, 3 );
+            fail( "Should object that the connection is closed." );
+        }
+        catch (SQLException se)
+        {
+            assertSQLState( CLOSED_CONNECTION, se );
+        }
+    }
+    
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java?rev=1063822&r1=1063821&r2=1063822&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Conn.java
Wed Jan 26 18:42:38 2011
@@ -96,6 +96,24 @@ public  class   Wrapper41Conn
         else { throw nothingWrapped(); }
     }
 
+    public  int    getNetworkTimeout() throws SQLException
+    {
+        if ( _embedded != null ) { return _embedded.getNetworkTimeout(); }
+        else if ( _netclient != null ) { return _netclient.getNetworkTimeout(); }
+        else if ( _brokeredConnection != null ) { return _brokeredConnection.getNetworkTimeout();
}
+        else if ( _logicalConnection != null ) { return _logicalConnection.getNetworkTimeout();
}
+        else { throw nothingWrapped(); }
+    }
+
+    public  void    setNetworkTimeout( Executor executor, int milliseconds ) throws SQLException
+    {
+        if ( _embedded != null ) { _embedded.setNetworkTimeout( executor, milliseconds );
}
+        else if ( _netclient != null ) { _netclient.setNetworkTimeout( executor, milliseconds
); }
+        else if ( _brokeredConnection != null ) { _brokeredConnection.setNetworkTimeout(
executor, milliseconds ); }
+        else if ( _logicalConnection != null ) { _logicalConnection.setNetworkTimeout( executor,
milliseconds ); }
+        else { throw nothingWrapped(); }
+    }
+
     ///////////////////////////////////////////////////////////////////////
     //
     // OTHER PUBLIC BEHAVIOR



Mime
View raw message