db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1063295 - 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/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
Date Tue, 25 Jan 2011 14:23:13 GMT
Author: rhillegas
Date: Tue Jan 25 14:23:12 2011
New Revision: 1063295

URL: http://svn.apache.org/viewvc?rev=1063295&view=rev
Log:
DERBY-4869: Wrap query timeout SQLState in a SQLTimeoutException per the JDBC 4.1 spec clarification.

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/StatementTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTestSetup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SetQueryTimeoutTest.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=1063295&r1=1063294&r2=1063295&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
Tue Jan 25 14:23:12 2011
@@ -30,6 +30,7 @@ import java.sql.SQLIntegrityConstraintVi
 import java.sql.SQLInvalidAuthorizationSpecException;
 import java.sql.SQLNonTransientConnectionException;
 import java.sql.SQLSyntaxErrorException;
+import java.sql.SQLTimeoutException;
 import java.sql.SQLTransactionRollbackException;
 
 
@@ -92,6 +93,8 @@ public class SQLExceptionFactory40 exten
             sqlState.equals(DRDA_REPLY_MSG_NOT_SUPPORTED)           ) {
             ex = new SQLFeatureNotSupportedException(message, sqlState, 
                     errCode);
+        } else if (sqlState.equals(SQLState.LANG_STATEMENT_CANCELLED_OR_TIMED_OUT.substring(0,
5))) {
+            ex = new SQLTimeoutException(message, sqlState, errCode);
         } else {
             ex = new SQLException(message, sqlState, errCode); 
         }

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=1063295&r1=1063294&r2=1063295&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
Tue Jan 25 14:23:12 2011
@@ -27,6 +27,7 @@ import java.sql.SQLIntegrityConstraintVi
 import java.sql.SQLInvalidAuthorizationSpecException;
 import java.sql.SQLNonTransientConnectionException;
 import java.sql.SQLSyntaxErrorException;
+import java.sql.SQLTimeoutException;
 import java.sql.SQLTransactionRollbackException;
 import java.sql.SQLFeatureNotSupportedException;
 import org.apache.derby.iapi.error.StandardException;
@@ -91,6 +92,8 @@ public class SQLExceptionFactory40 exten
             ex = new SQLSyntaxErrorException(message, sqlState, severity, t);
         } else if (sqlState.startsWith(SQLState.UNSUPPORTED_PREFIX)) {
             ex = new SQLFeatureNotSupportedException(message, sqlState, severity, t);
+        } else if (sqlState.equals(SQLState.LANG_STATEMENT_CANCELLED_OR_TIMED_OUT.substring(0,
5))) {
+            ex = new SQLTimeoutException(message, sqlState, severity, t);
         } else {
             ex = new SQLException(message, sqlState, severity, t);
         }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java?rev=1063295&r1=1063294&r2=1063295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTest.java
Tue Jan 25 14:23:12 2011
@@ -1,6 +1,6 @@
 /*
  *
- * Derby - Class StatementTest
+ * Derby - Class org.apache.derbyTesting.functionTests.tests.jdbc4.StatementTest
  *
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -20,6 +20,7 @@
 
 package org.apache.derbyTesting.functionTests.tests.jdbc4;
 
+import org.apache.derbyTesting.functionTests.tests.jdbcapi.SetQueryTimeoutTest;
 import org.apache.derbyTesting.functionTests.util.SQLStateConstants;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.TestConfiguration;
@@ -265,6 +266,34 @@ public class StatementTest
     }
 
     /**
+     * Test that Statement.setQueryTimeout() causes statements to
+     * raise SQLTimeoutException per the JDBC 4.1 spec clarification.
+     */
+    public  void    test_jdbc4_1_queryTimeoutException() throws Exception
+    {
+        PreparedStatement ps = prepareStatement
+            (
+             "select columnnumber from sys.syscolumns c, sys.systables t\n" +
+             "where t.tablename = 'SYSTABLES'\n" +
+             "and t.tableid = c.referenceid\n" +
+             "and c.columnnumber = delay_st( 5, 1 )"
+             );
+        println( "Testing timeout exception for a " + ps.getClass().getName() );
+
+        SetQueryTimeoutTest.StatementExecutor   executor =
+            new SetQueryTimeoutTest.StatementExecutor( ps, true, 1 );
+
+        executor.start();
+        executor.join();
+
+        ps.close();
+
+        SQLException    se = executor.getSQLException();
+        assertNotNull( se );
+        assertEquals( SQLTimeoutException.class.getName(), se.getClass().getName() );
+    }
+
+    /**
      * Create test suite for StatementTest.
      */
     public static Test suite() {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTestSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTestSetup.java?rev=1063295&r1=1063294&r2=1063295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTestSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/StatementTestSetup.java
Tue Jan 25 14:23:12 2011
@@ -69,6 +69,15 @@ public class StatementTestSetup 
                     "42X05",
                     sqle.getSQLState());
         }
+
+        try {
+            stmt.execute("drop function delay_st");
+        }
+        catch (SQLException se)
+        {
+            // ignore object does not exist error
+            assertEquals( "42Y55", se.getSQLState() );
+        }
         stmt.execute("create table stmtTable (id int, val varchar(10))");
         stmt.execute("insert into stmtTable values (1, 'one'),(2,'two')");
         // Check just to be sure, and to notify developers if the database
@@ -78,6 +87,12 @@ public class StatementTestSetup 
         assertEquals("Number of rows are not as expected", 
                 2, rs.getInt(1));
         rs.close();
+        stmt.execute
+            (
+             "create function delay_st(seconds integer, value integer) returns integer\n"
+
+             "parameter style java no sql language java\n" +
+             "external name 'org.apache.derbyTesting.functionTests.tests.jdbcapi.SetQueryTimeoutTest.delay'"
+             );
         stmt.close();
         con.commit();
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SetQueryTimeoutTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SetQueryTimeoutTest.java?rev=1063295&r1=1063294&r2=1063295&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SetQueryTimeoutTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SetQueryTimeoutTest.java
Tue Jan 25 14:23:12 2011
@@ -276,7 +276,7 @@ public class SetQueryTimeoutTest
             + tablePrefix + "_orig where DELAY(1,1)=1";
     }
     
-    private static class StatementExecutor
+    public static class StatementExecutor
         extends
             Thread
     {



Mime
View raw message