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 da...@apache.org on 2006/02/13 22:47:37 UTC

svn commit: r377503 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/jdbc/ engine/org/apache/derby/jdbc/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/suites/ testing/org/apache/derbyTes...

Author: davidvc
Date: Mon Feb 13 13:47:35 2006
New Revision: 377503

URL: http://svn.apache.org/viewcvs?rev=377503&view=rev
Log:
DERBY-968: Added new metadata methods to embedded client.  This
revision returns EMPTY RESULT SETS for the new methods getFunctions()
and getFunctionParameters(). DERBY-924 and DERBY-925 have been opened
for these, and linked to this issue.

I also fixed some existing metadata calls that throw a not-implemented
exception when they should have been returning empty result sets.

I also fixed a bug in Driver40 where it did not override 
newEmbedDatabaseMetaData(), so EmbedDatabaseMetaData40 was not being
used.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java   (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData_app.properties   (with props)
Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dbMetaDataJdbc30.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc4.runall
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/build.xml
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/copyfiles.ant
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/dbMetaDataJdbc30.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultsetJdbc30.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java?rev=377503&r1=377502&r2=377503&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java Mon Feb 13 13:47:35 2006
@@ -98,7 +98,7 @@
 	*/
 
 	private	GenericConstantActionFactory	constantActionFactory;
-
+    
 	//////////////////////////////////////////////////////////////
 	//
 	// CONSTRUCTORS
@@ -3026,7 +3026,7 @@
 	public boolean locatorsUpdateCopy()
     throws SQLException
 	{
-		throw Util.notImplemented();
+		return false;
 	}
 
 	/**
@@ -3046,7 +3046,7 @@
 	public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern)
     throws SQLException
 	{
-		throw Util.notImplemented();
+		return getSimpleQuery("getSuperTypes");
 	}
 
 	/**
@@ -3060,12 +3060,12 @@
     * @param schemaPattern - a schema name pattern; "" retrieves those without a schema
     * @param typeNamePattern - a UDT name pattern; may be a fully-qualified name
     * @return a ResultSet object in which each row is a type description
-    * @exception SQLException Feature not implemented for now.
+    * @exception SQLException if a database access error occurs
 	*/
 	public ResultSet getSuperTables(String catalog, String schemaPattern, String typeNamePattern)
     throws SQLException
 	{
-		throw Util.notImplemented();
+		return getSimpleQuery("getSuperTables");
 	}
 
 	/**
@@ -3084,13 +3084,13 @@
     * @param attributeNamePattern - an attribute name pattern; must match the attribute
     * name as it is declared in the database
     * @return a ResultSet object in which each row is a type description
-    * @exception SQLException Feature not implemented for now.
+    * @exception SQLException if a database access error occurs.
 	*/
 	public ResultSet getAttributes(String catalog, String schemaPattern,
   String typeNamePattern, String attributeNamePattern)
     throws SQLException
 	{
-		throw Util.notImplemented();
+        return getSimpleQuery("getAttributes");
 	}
 	
 	//////////////////////////////////////////////////////////////
@@ -3103,7 +3103,7 @@
 	 * utility helper routines:
 	 */
 
-	private ResultSet getSimpleQuery(String nameKey) throws SQLException
+	protected ResultSet getSimpleQuery(String nameKey) throws SQLException
 	{
 		PreparedStatement ps = getPreparedQuery(nameKey);
 		if (ps == null)
@@ -3124,9 +3124,8 @@
 				String queryText = getQueryDescriptions().getProperty(nameKey);
 				if (queryText == null)
 				{
-					throw Util.notImplemented(nameKey);
+                    throw Util.notImplemented(nameKey);
 				}
-
 				
                 ps = prepareSPS(nameKey, queryText);
 			}
@@ -3157,7 +3156,7 @@
 	 * a prepared statement
 	 * @return PreparedStatement
 	 */
-	private PreparedStatement getPreparedQuery(String queryName)
+	protected PreparedStatement getPreparedQuery(String queryName)
 			throws SQLException {
 		PreparedStatement s;
 		//We can safely goto system table since we are not in soft upgrade

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java?rev=377503&r1=377502&r2=377503&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData40.java Mon Feb 13 13:47:35 2006
@@ -22,7 +22,9 @@
 
 import java.sql.ResultSet;
 import java.sql.RowIdLifetime;
+import java.sql.DatabaseMetaData;
 import java.sql.SQLException;
+import java.sql.PreparedStatement;
 import org.apache.derby.impl.jdbc.Util;
 
 
@@ -36,30 +38,50 @@
     }
    
     public RowIdLifetime getRowIdLifetime() throws SQLException {
-        throw Util.notImplemented();
-        
+        return RowIdLifetime.ROWID_UNSUPPORTED;
     }
 
     
     public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
-        throw Util.notImplemented();
+		PreparedStatement s = getPreparedQuery("getSchemasWithParams");
+		s.setString(1, swapNull(catalog));
+		s.setString(2, swapNull(schemaPattern));
+		return s.executeQuery();
     }
     
     
     public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
-        throw Util.notImplemented();
+        return true;
     }
      
     public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
-        throw Util.notImplemented();
+        // TODO - find out what this really should be 
+        return false;
     }
    
-    public ResultSet getClientInfoProperties()
-		throws SQLException {
-        throw Util.notImplemented();
+    public ResultSet getClientInfoProperties() throws SQLException {
+        return getSimpleQuery("getClientInfoProperties");
     }
    
     public boolean providesQueryObjectGenerator() throws SQLException {
-        throw Util.notImplemented();
+        return false;
     }
+    
+    public ResultSet getFunctions(java.lang.String catalog,
+                       java.lang.String schemaPattern,
+                       java.lang.String functionNamePattern)
+                       throws SQLException
+    {
+        return getSimpleQuery("getFunctions");
+    }
+    
+    public ResultSet getFunctionParameters(java.lang.String catalog,
+                                java.lang.String schemaPattern,
+                                java.lang.String functionNamePattern,
+                                java.lang.String parameterNamePattern)
+                                throws SQLException
+    {
+        return getSimpleQuery("getFunctionParameters");
+    }
+
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties?rev=377503&r1=377502&r2=377503&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/metadata.properties Mon Feb 13 13:47:35 2006
@@ -60,6 +60,20 @@
 	FROM SYS.SYSSCHEMAS \
 	ORDER BY TABLE_SCHEM
 
+#
+# getSchemas with parameters - new with JDK 1.6
+#
+# parameter 1 = catalog name pattern  (not used)
+# parameter 2 = schema name pattern
+#
+getSchemasWithParams=\
+        SELECT SCHEMANAME AS TABLE_SCHEM, \
+          CAST(NULL AS VARCHAR(128)) AS TABLE_CATALOG \
+          FROM SYS.SYSSCHEMAS \
+	  WHERE ((1=1) OR ? IS NOT NULL) \
+          AND SCHEMANAME LIKE ? \
+          ORDER BY TABLE_SCHEM
+
 # REMIND: presently table_type is a single char, we match JDBC
 # recommendations closer and make it a more obvious word.
 # REMIND: fillers for catalog names' comparisons
@@ -920,3 +934,99 @@
 	WHERE ((1=1) OR ? IS NOT NULL) AND ((1=1) OR ? IS NOT NULL) AND ALIAS LIKE ? \
 	AND ?<>0 AND ALIASTYPE = 'C' \
 	ORDER BY DATA_TYPE, TYPE_SCHEM, TYPE_NAME
+
+#
+# getSuperTypes is not supported, so we return an empty result set of the right
+# shape
+#
+getSuperTypes=SELECT \
+        CAST(NULL AS VARCHAR(128)) AS TYPE_CAT, \
+        CAST(NULL AS VARCHAR(128)) AS TYPE_SCHEM, \
+        VARCHAR('', 128) AS TYPE_NAME, \
+        CAST(NULL AS VARCHAR(128)) AS SUPERTYPE_CAT, \
+        CAST(NULL AS VARCHAR(128)) AS SUPERTYPE_SCHEM, \
+        VARCHAR('', 128) AS SUPERTYPE_NAME \
+    FROM SYSIBM.SYSDUMMY1 WHERE 1=0 WITH UR 
+
+getAttributes=SELECT \
+        CAST(NULL AS VARCHAR(128)) AS TYPE_CAT, \
+        CAST(NULL AS VARCHAR(128)) AS TYPE_SCHEM, \
+        VARCHAR('', 128) AS TYPE_NAME, \
+        CAST(NULL AS VARCHAR(128)) AS ATTR_NAME, \
+        CAST(NULL AS INT) AS DATA_TYPE, \
+        CAST(NULL AS VARCHAR(128)) AS ATTR_TYPE_NAME, \
+        CAST(NULL AS INT) AS ATTR_SIZE, \
+        CAST(NULL AS INT) AS DECIMAL_DIGITS, \
+        CAST(NULL AS INT) AS NUM_PREC_RADIX, \
+        CAST(NULL AS INT) AS NULLABLE, \
+        CAST(NULL AS VARCHAR(128)) AS REMARKS, \
+        CAST(NULL AS VARCHAR(128)) AS ATTR_DEF, \
+        CAST(NULL AS INT) AS SQL_DATA_TYPE, \
+        CAST(NULL AS INT) AS SQL_DATETIME_SUB, \
+        CAST(NULL AS INT) AS CHAR_OCTET_LENGTH, \
+        CAST(NULL AS INT) AS ORDINAL_POSITION, \
+        CAST(NULL AS VARCHAR(128)) AS IS_NULLABLE, \
+        CAST(NULL AS VARCHAR(128)) AS SCOPE_CATALOG, \
+        CAST(NULL AS VARCHAR(128)) AS SCOPE_SCHEMA, \
+        CAST(NULL AS VARCHAR(128)) AS SCOPE_TABLE, \
+        CAST(NULL AS SMALLINT) AS SOURCE_DATA_TYPE \
+    FROM SYSIBM.SYSDUMMY1 WHERE 1=0 WITH UR 
+
+#
+# getSuperTables is not supported, so we return an empty result set of the right
+# shape
+#
+getSuperTables=SELECT \
+        CAST(NULL AS VARCHAR(128)) AS TABLE_CAT, \
+        CAST(NULL AS VARCHAR(128)) AS TABLE_SCHEM, \
+        VARCHAR('', 128) AS TABLE_NAME, \
+        VARCHAR('', 128) AS SUPERTABLE_NAME \
+    FROM SYSIBM.SYSDUMMY1 WHERE 1=0 WITH UR
+
+
+#
+# getClientInfoProperties is not supported, so we return an empty result set
+# of the right shape
+#
+getClientInfoProperties=SELECT \
+        CAST(NULL AS VARCHAR(128)) AS NAME, \
+        CAST(NULL AS INT) AS MAX_LEN, \
+        CAST(NULL AS VARCHAR(128)) AS DEFAULT_VALUE, \
+        CAST(NULL AS VARCHAR(128)) AS DESCRIPTION \
+    FROM SYSIBM.SYSDUMMY1 WHERE 1=0 WITH UR
+
+#
+# getFunctions - Not yet implemented.  Logged in JIRA as DERBY-924
+# Return an empty result set with the right shape.
+#
+getFunctions=SELECT \
+        CAST(NULL AS VARCHAR(128)) AS FUNCTION_CAT, \
+        CAST(NULL AS VARCHAR(128)) AS FUNCTION_SCHEM, \
+        CAST(NULL AS VARCHAR(128)) AS FUNCTION_NAME, \
+        CAST(NULL AS VARCHAR(128)) AS REMARKS, \
+        CAST(NULL AS VARCHAR(128)) AS SPECIFIC_NAME \
+    FROM SYSIBM.SYSDUMMY1 WHERE 1=0 WITH UR
+
+#
+# getFunctionParameters - Not yet implemented.  Logged in JIRA as DERBY-925
+# Return an empty result set with the right shape.
+#
+getFunctionParameters=SELECT \
+        CAST(NULL AS VARCHAR(128)) AS FUNCTION_CAT, \
+        CAST(NULL AS VARCHAR(128)) AS FUNCTION_SCHEM, \
+        CAST(NULL AS VARCHAR(128)) AS PARAMETER_NAME, \
+        CAST(NULL AS SMALLINT) AS PARAMETER_TYPE, \
+        CAST(NULL AS INT) AS DATA_TYPE, \
+        CAST(NULL AS VARCHAR(128)) AS TYPE_NAME, \
+        CAST(NULL AS INT) AS PRECISION, \
+        CAST(NULL AS INT) AS LENGTH, \
+        CAST(NULL AS SMALLINT) AS SCALE, \
+        CAST(NULL AS SMALLINT) AS RADIX, \
+        CAST(NULL AS SMALLINT) AS NULLABLE, \
+        CAST(NULL AS VARCHAR(128)) AS REMARKS, \
+        CAST(NULL AS INT) AS CHAR_OCTET_LENGTH, \
+        CAST(NULL AS INT) AS ORDINAL_POSITION, \
+        CAST(NULL AS VARCHAR(128)) AS IS_NULLABLE, \
+        CAST(NULL AS VARCHAR(128)) AS SPECIFIC_NAME \
+    FROM SYSIBM.SYSDUMMY1 WHERE 1=0 WITH UR
+

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java?rev=377503&r1=377502&r2=377503&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java Mon Feb 13 13:47:35 2006
@@ -20,6 +20,7 @@
 
 package org.apache.derby.jdbc;
 
+import java.sql.DatabaseMetaData;
 import org.apache.derby.iapi.jdbc.BrokeredConnection;
 import org.apache.derby.iapi.jdbc.BrokeredConnectionControl;
 import org.apache.derby.iapi.jdbc.BrokeredConnection40;
@@ -33,6 +34,7 @@
 import org.apache.derby.impl.jdbc.EmbedConnection40;
 import org.apache.derby.impl.jdbc.EmbedResultSet;
 import org.apache.derby.impl.jdbc.EmbedResultSet40;
+import org.apache.derby.impl.jdbc.EmbedDatabaseMetaData40;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.CallableStatement;
@@ -106,5 +108,10 @@
     
     public EmbedRowId newEmbedRowId() throws SQLException {
         return new EmbedRowId();
+    }
+
+    public DatabaseMetaData newEmbedDatabaseMetaData(EmbedConnection conn, String dbname) 
+        throws SQLException {
+		return new EmbedDatabaseMetaData40(conn,dbname);
     }
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dbMetaDataJdbc30.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dbMetaDataJdbc30.out?rev=377503&r1=377502&r2=377503&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dbMetaDataJdbc30.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/dbMetaDataJdbc30.out Mon Feb 13 13:47:35 2006
@@ -21,11 +21,11 @@
 getMaxTableNameLength() = 128
 getMaxUserNameLength() = 30
 getSuperTypes() with null :
-EXPECTED: Not Implemented Exception or empty  ResultSet
+EXPECTED: Empty ResultSet
 getSuperTables() with null :
-EXPECTED: Not Implemented Exception or empty  ResultSet
+EXPECTED: Empty ResultSet
 getAttributes() with null :
-EXPECTED: Not Implemented Exception or empty  ResultSet
+EXPECTED: Empty ResultSet
 locatorsUpdateCopy(): 
-Expected : Feature not implemented: no details.
+Returned: false
 Test dbMetaDataJdbc30 finished

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc4.runall
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc4.runall?rev=377503&r1=377502&r2=377503&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc4.runall (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/suites/jdbc4.runall Mon Feb 13 13:47:35 2006
@@ -3,3 +3,4 @@
 jdbc4/TestCallableStatementMethods.java
 jdbc4/TestPreparedStatementMethods.java
 jdbc4/TestResultSetMethods.java
+jdbc4/TestDbMetaData.java

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java?rev=377503&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java Mon Feb 13 13:47:35 2006
@@ -0,0 +1,187 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.tests.jdbc.TestDbMetaData
+
+   Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+ */
+
+package org.apache.derbyTesting.functionTests.tests.jdbc4;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.RowIdLifetime;
+
+import org.apache.derby.tools.ij;
+
+/**
+ * Test of database meta-data for new methods in jdbc 30. This program simply calls
+ * each of the new meta-data methods in jdbc30, one by one, and prints the results.
+ *
+ * @author mamta
+ */
+
+public class TestDbMetaData { 
+
+	public static void main(String[] args) {
+		DatabaseMetaData met;
+		Connection con;
+		Statement  s;
+    
+		try
+		{
+            // Using this for now instead of ij because ij.startJBMS()
+            // returns null for classes built against JDK 1.6
+            con = new TestConnection().createEmbeddedConnection();
+
+			con.setAutoCommit(true); // make sure it is true
+
+			s = con.createStatement();
+            
+			met = con.getMetaData();
+
+            if ( ! met.supportsStoredFunctionsUsingCallSyntax() ) {
+                throw new Exception("FAIL: supportsStoredFunctionsUsingCallSyntax() " +
+                    "should return true");
+            }
+            
+            if ( met.autoCommitFailureClosesAllResultSets() ) {
+                throw new Exception("FAIL: autoCommitFailureClosesAllResultSets() " +
+                    "should return false");
+            }
+            
+            if ( met.providesQueryObjectGenerator() ) {
+                throw new Exception("FAIL: providesQueryObjectGenerator() should " +
+                    "return false");
+            }
+            
+            RowIdLifetime lifetime = met.getRowIdLifetime();
+            if ( lifetime != RowIdLifetime.ROWID_UNSUPPORTED ) {
+                throw new Exception("FAIL: getRowIdLifetime() should return " +
+                    "ROWID_UNSUPPORTED, but got " + lifetime );
+            }
+
+			checkEmptyRS(met.getClientInfoProperties());
+
+			checkEmptyRS(met.getFunctions(null,null,null));
+        
+			checkEmptyRS(met.getFunctionParameters(null,null,null,null));
+            
+            // 
+            // Test the new getSchemas() with no schema qualifiers
+            //
+            dumpRS(met.getSchemas(null, null));
+            
+            //
+            // Test the new getSchemas() with a schema wildcard qualifier
+            // 
+            dumpRS(met.getSchemas(null, "SYS%"));
+            
+            // 
+            // Test the new getSchemas() with an exact match
+            //
+            dumpRS(met.getSchemas(null, "APP"));
+            
+            //
+            // Make sure that getSchemas() returns an empty result
+            // set when a schema is passed with no match
+            //
+            checkEmptyRS(met.getSchemas(null, "BLAH"));
+        
+			s.close();
+
+			con.close();
+
+		}
+		catch (SQLException e) {
+			dumpSQLExceptions(e);
+		}
+		catch (Throwable e) {
+			System.out.println("FAIL -- unexpected exception:");
+			e.printStackTrace(System.out);
+		}
+    }
+
+	static private void dumpSQLExceptions (SQLException se) {
+		System.out.println("FAIL -- unexpected exception");
+		while (se != null) {
+			System.out.print("SQLSTATE("+se.getSQLState()+"):");
+			se.printStackTrace(System.out);
+			se = se.getNextException();
+		}
+	}
+
+	static void dumpRS(ResultSet s) throws SQLException {
+		ResultSetMetaData rsmd = s.getMetaData ();
+
+		// Get the number of columns in the result set
+		int numCols = rsmd.getColumnCount ();
+
+		if (numCols <= 0) {
+			System.out.println("(no columns!)");
+			return;
+		}
+		
+		// Display column headings
+		for (int i=1; i<=numCols; i++) {
+			if (i > 1) System.out.print(",");
+			System.out.print(rsmd.getColumnLabel(i));
+		}
+		System.out.println();
+	
+		// Display data, fetching until end of the result set
+		while (s.next()) {
+			// Loop through each column, getting the
+			// column data and displaying
+			for (int i=1; i<=numCols; i++) {
+				if (i > 1) System.out.print(",");
+				System.out.print(s.getString(i));
+			}
+			System.out.println();
+		}
+		s.close();
+	}
+
+	/**
+	 * Checks for a ResultSet with no rows.
+	 *
+	 */
+	static void checkEmptyRS(ResultSet rs) throws Exception
+	{		
+		boolean passed = false;
+
+		try {
+			if ( rs == null )
+            {
+                throw new Exception("Metadata result set can not be null");
+            }
+            int numrows = 0;
+            while (rs.next())
+                numrows++;
+            // Zero rows is what we want.
+            if (numrows != 0) {
+                throw new Exception("Result set is not empty");
+            }
+		}
+		catch (SQLException e)
+		{
+			throw new Exception("Unexpected SQL Exception: " + e.getMessage(), e);
+		}
+	}
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData_app.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData_app.properties?rev=377503&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData_app.properties (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData_app.properties Mon Feb 13 13:47:35 2006
@@ -0,0 +1,6 @@
+# caching helps out metadata test (reduced from 5 to 3 minutes)
+usedefaults=true
+runwithjdk13=false
+runwithjdk14=false
+runwithibm13=false
+runwithj9=false

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData_app.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java?rev=377503&r1=377502&r2=377503&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestPreparedStatementMethods.java Mon Feb 13 13:47:35 2006
@@ -29,6 +29,8 @@
 import java.sql.SQLXML;
 import org.apache.derby.impl.jdbc.Util;
 
+import org.apache.derby.tools.ij;
+
 public class TestPreparedStatementMethods {
     
     Connection conn=null;

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/build.xml
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/build.xml?rev=377503&r1=377502&r2=377503&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/build.xml (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/build.xml Mon Feb 13 13:47:35 2006
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<project default="compile_jdbc4" basedir="../../../../../../../..">
+<project default="compile" basedir="../../../../../../../..">
 
     <property file="${user.home}/ant.properties"/>
 
@@ -57,5 +57,7 @@
             includesfile="${derby.testing.src.dir}/${derby.testing.functest.dir}/tests/jdbc4/copyfiles.ant"/>
         </copy>
     </target>
+    
+    <target name="compile" depends="compile_jdbc4"/>
 
 </project>

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/copyfiles.ant
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/copyfiles.ant?rev=377503&r1=377502&r2=377503&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/copyfiles.ant (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/copyfiles.ant Mon Feb 13 13:47:35 2006
@@ -3,3 +3,5 @@
 TestRowId_app.properties
 TestConnectionMethods_app.properties
 TestResultSetMethods_app.properties
+TestDbMetaData_app.properties
+

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/dbMetaDataJdbc30.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/dbMetaDataJdbc30.java?rev=377503&r1=377502&r2=377503&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/dbMetaDataJdbc30.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/dbMetaDataJdbc30.java Mon Feb 13 13:47:35 2006
@@ -134,40 +134,22 @@
 			//following will give not implemented exceptions.
 			// JCC will return an empty result set, so either a
 			// result set with no rows or an exception will pass
-			try {
-			  System.out.println();
-			  System.out.println("getSuperTypes() with null :");
-			  checkEmptyRSOrNotImplemented(met.getSuperTypes(null,null,null),null);
- 			} catch (SQLException ex) {
-				checkEmptyRSOrNotImplemented(null,ex);
- 			}
-
-			try {
-			  System.out.println();
-			  System.out.println("getSuperTables() with null :");
-			  checkEmptyRSOrNotImplemented(met.getSuperTables(null,null,null),null);
- 			} catch (SQLException ex) {
-				checkEmptyRSOrNotImplemented(null,ex);
- 			}
-
-			try {
-			  System.out.println();
-			  System.out.println("getAttributes() with null :");
-
- 			  checkEmptyRSOrNotImplemented(met.getAttributes(null, null, null,
-															 null), null);
- 			} catch (SQLException ex) {
-				checkEmptyRSOrNotImplemented(null,ex);
- 			}
-
-			try {
-			  System.out.println();
-			  System.out.println("locatorsUpdateCopy(): ");
-			  // JCC doesn't throw exception, Embedded driver does.
-			  System.out.println("Returned: " + met.locatorsUpdateCopy());
- 			} catch (SQLException ex) {
-			  System.out.println("Expected : " + ex.getMessage());
- 			}
+			System.out.println();
+			System.out.println("getSuperTypes() with null :");
+			checkEmptyRS(met.getSuperTypes(null,null,null));
+
+			System.out.println();
+			System.out.println("getSuperTables() with null :");
+			checkEmptyRS(met.getSuperTables(null,null,null));
+
+            System.out.println();
+            System.out.println("getAttributes() with null :");
+
+ 			checkEmptyRS(met.getAttributes(null, null, null, null));
+
+            System.out.println();
+			System.out.println("locatorsUpdateCopy(): ");
+			System.out.println("Returned: " + met.locatorsUpdateCopy());
         
 			s.close();
 
@@ -194,7 +176,7 @@
 		}
 	}
 
-	static void dumpRS(ResultSet s) throws SQLException {
+	public static void dumpRS(ResultSet s) throws SQLException {
 		ResultSetMetaData rsmd = s.getMetaData ();
 
 		// Get the number of columns in the result set
@@ -226,18 +208,15 @@
 	}
 
 	/**
-	 * JCC returns an empty resultset instead of throwing an exception
-	 * for some methods.
-	 * Checks for either a ResultSet with no rows or a NotImplemented  
-	 * exception.  Usually either the rs or se are null.
-	 *
+  	 * In order to be JDBC compliant, all metadata calls must return valid
+     * results, even if it's an empty result set.  It should be considered
+     * a failure if we throw an exception
 	 */
-	static void checkEmptyRSOrNotImplemented(ResultSet rs, SQLException se)
+	public static void checkEmptyRS(ResultSet rs)
 	{		
 		boolean passed = false;
 
 		try {
-			
 			if (rs != null)
 			{
 				int numrows = 0;
@@ -247,13 +226,6 @@
 				if (numrows == 0)
 					passed = true;			
 			}
-			else if (se != null)
-			{
-				// Not implemented exception is OK too.
-				String sqlState =se.getSQLState();
-				if (sqlState != null && sqlState.startsWith("0A"))
-				passed = true;
-			}
 		}
 		catch (SQLException e)
 		{
@@ -264,9 +236,9 @@
 		finally 
 		{
 			if (passed)
-				System.out.println("EXPECTED: Not Implemented Exception or empty  ResultSet");
+				System.out.println("EXPECTED: Empty ResultSet");
 			else 
-				System.out.println("FAIL:  Should have gotten Not Implemented Exception or empty ResultSet");
+				System.out.println("FAIL: Should have gotten empty ResultSet");
 		}
 	}
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultsetJdbc30.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultsetJdbc30.java?rev=377503&r1=377502&r2=377503&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultsetJdbc30.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultsetJdbc30.java Mon Feb 13 13:47:35 2006
@@ -163,8 +163,39 @@
  			}
 
 			rs.close();
-
 			stmt.close();
+            
+            //
+            // Check our behavior around closing result sets when auto-commit
+            // is true.  Test with both holdable and non-holdable result sets
+            //
+            con.setAutoCommit(true);
+            
+            // Create a non-updatable holdable result set, and then try to 
+            // update it
+            stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+                ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
+            
+			rs = stmt.executeQuery("select * from t");
+			rs.next();
+            
+            checkForCloseOnException(rs, true);
+            
+            rs.close();
+            stmt.close();
+
+            // Create a non-updatable non-holdable result set, and then try to 
+            // update it
+            stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
+                ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT);
+            
+			rs = stmt.executeQuery("select * from t");
+			rs.next();
+            
+            checkForCloseOnException(rs, false);
+                
+            rs.close();
+            stmt.close();
 			con.close();
 
 		}
@@ -175,9 +206,37 @@
 		catch (Throwable e) {
 			System.out.println("FAIL -- unexpected exception: "+e);
 			e.printStackTrace();
-		}
+		}   
 
 		System.out.println("Test resultsetJdbc30 finished");
+    }
+    
+    static private void checkForCloseOnException(ResultSet rs, boolean holdable) 
+            throws Exception {
+        try {
+            rs.updateBlob("c",null);
+            throw new Exception("rs.updateBlob() on a read-only result set" +
+                "should not have succeeded");
+        } catch (SQLException ex) {
+        }
+
+        try {
+            rs.beforeFirst();
+            String holdableStr = holdable ? "holdable" : "non-holdable";
+            System.out.println(holdableStr + " result set was not closed on exception");
+        }
+        catch ( SQLException ex) {
+            String state = ex.getSQLState();
+            if ( state.equals("XCL16"))
+            {
+                System.out.println("Holdable result set was closed on exception");
+            }
+            else
+            {
+                throw ex;
+            }
+        }
+
     }
 
 	static private void dumpSQLExceptions (SQLException se) {