db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r432028 - in /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests: jdbcapi/ProcedureTest.java jdbcapi/SURBaseTest.java jdbcapi/SURDataModelSetup.java tools/sysinfo_api.java
Date Wed, 16 Aug 2006 20:42:18 GMT
Author: djd
Date: Wed Aug 16 13:42:18 2006
New Revision: 432028

URL: http://svn.apache.org/viewvc?rev=432028&view=rev
Log:
DERBY-1555 DERBY-1701 (partial) Convert more tests to use the instance based get[X]Connection
method
or the static openDefault method.

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ProcedureTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ProcedureTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ProcedureTest.java?rev=432028&r1=432027&r2=432028&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ProcedureTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ProcedureTest.java
Wed Aug 16 13:42:18 2006
@@ -592,14 +592,19 @@
     public void testDynamicResultSetsFromOtherConnectionWithExecuteQuery()
         throws SQLException
     {
-        Statement stmt = getXConnection().createStatement();
+        PreparedStatement ps =
+            getXConnection().prepareStatement("CALL RETRIEVE_EXTERNAL_RESULT(?,?,?)");
+        
+        ps.setString(1, getTestConfiguration().getDatabaseName());
+        ps.setString(2, getTestConfiguration().getUserName());
+        ps.setString(3, getTestConfiguration().getUserPassword());
         try {
-            ResultSet rs = stmt.executeQuery("CALL RETRIEVE_EXTERNAL_RESULT()");
+            ps.executeQuery();
             fail("executeQuery() didn't fail.");
         } catch (SQLException sqle) {
             assertNoResultSetFromExecuteQuery(sqle);
         }
-        stmt.close();
+        ps.close();
     }
 
     /**
@@ -610,9 +615,15 @@
     public void testDynamicResultSetsFromOtherConnectionWithExecuteUpdate()
         throws SQLException
     {
-        Statement stmt = getXConnection().createStatement();
-        stmt.executeUpdate("CALL RETRIEVE_EXTERNAL_RESULT()");
-        stmt.close();
+        PreparedStatement ps =
+            getXConnection().prepareStatement("CALL RETRIEVE_EXTERNAL_RESULT(?,?,?)");
+        
+        ps.setString(1, getTestConfiguration().getDatabaseName());
+        ps.setString(2, getTestConfiguration().getUserName());
+        ps.setString(3, getTestConfiguration().getUserPassword());
+        
+        ps.executeUpdate();
+        ps.close();
     }
 
     // UTILITY METHODS
@@ -790,7 +801,8 @@
           "DYNAMIC RESULT SETS 1"
         },
         { "RETRIEVE_EXTERNAL_RESULT",
-          "CREATE PROCEDURE RETRIEVE_EXTERNAL_RESULT() LANGUAGE JAVA " +
+          "CREATE PROCEDURE RETRIEVE_EXTERNAL_RESULT(" +
+          "DBNAME VARCHAR(128), DBUSER VARCHAR(128), DBPWD VARCHAR(128)) LANGUAGE JAVA "
+
           "PARAMETER STYLE JAVA EXTERNAL NAME '" +
           ProcedureTest.class.getName() + ".retrieveExternalResult' " +
           "DYNAMIC RESULT SETS 1"
@@ -872,11 +884,17 @@
      * @param external result set from another connection
      * @exception SQLException if a database error occurs
      */
-    public static void retrieveExternalResult(ResultSet[] external)
+    public static void retrieveExternalResult(String dbName, 
+            String user, String password, ResultSet[] external)
         throws SQLException
     {
+        // Use a server-side connection to the same database.
+        String url = "jdbc:derby:" + dbName;
+        
+        Connection conn = DriverManager.getConnection(url, user, password);
+        
         external[0] =
-            getConnection().createStatement().executeQuery("VALUES(1)");
+            conn.createStatement().executeQuery("VALUES(1)");
     }
 
     /**

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java?rev=432028&r1=432027&r2=432028&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURBaseTest.java
Wed Aug 16 13:42:18 2006
@@ -55,7 +55,7 @@
     protected Connection getNewConnection() 
         throws SQLException
     {
-        final Connection rcon = getConnection();
+        final Connection rcon = openDefaultConnection();
         rcon.setAutoCommit(false);
         rcon.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
         return rcon;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java?rev=432028&r1=432027&r2=432028&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/SURDataModelSetup.java
Wed Aug 16 13:42:18 2006
@@ -162,7 +162,7 @@
     private Connection getNewConnection() 
         throws SQLException
     {
-        final Connection rcon = SURBaseTest.getConnection();
+        final Connection rcon = SURBaseTest.openDefaultConnection();
         rcon.setAutoCommit(false);
         return rcon;
     }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java?rev=432028&r1=432027&r2=432028&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/sysinfo_api.java
Wed Aug 16 13:42:18 2006
@@ -38,7 +38,6 @@
 
 public class sysinfo_api extends BaseJDBCTestCase {
 
-    Connection c;
     DatabaseMetaData dm;
 
     public sysinfo_api(String name) { 
@@ -139,13 +138,9 @@
      *              with sysinfo
      */
     public void setUp() throws SQLException {
-        c = getConnection();
-        dm = c.getMetaData();
+        dm = getXConnection().getMetaData();
     }
 
-    public void tearDown() throws SQLException {
-        c.close();
-    }
 
 }
 



Mime
View raw message