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 ka...@apache.org on 2006/04/20 13:15:26 UTC
svn commit: r395561 - in /db/derby/code/trunk/java:
client/org/apache/derby/client/am/ client/org/apache/derby/client/net/
engine/org/apache/derby/catalog/ engine/org/apache/derby/impl/jdbc/
testing/org/apache/derbyTesting/functionTests/master/ testing...
Author: kahatlen
Date: Thu Apr 20 04:15:20 2006
New Revision: 395561
URL: http://svn.apache.org/viewcvs?rev=395561&view=rev
Log:
DERBY-970: Add new metadata methods to network client driver
Added the JDBC 4.0 methods DatabaseMetaData.getSchemas() and
DatabaseMetaData.getClientInfoProperties() to the client driver.
Modified:
db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java
db/derby/code/trunk/java/client/org/apache/derby/client/net/NetDatabaseMetaData40.java
db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java
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/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/metadata.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/metadata.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/odbc_metadata.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/metadata.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/odbc_metadata.out
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/metadata_test.java
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java?rev=395561&r1=395560&r2=395561&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/DatabaseMetaData.java Thu Apr 20 04:15:20 2006
@@ -2497,6 +2497,131 @@
return false;
}
+ /**
+ * Get the schema names available in this database. The results
+ * are ordered by schema name.
+ *
+ * <p>The schema columns are:
+ * <ol>
+ * <li><strong>TABLE_SCHEM</strong> String => schema name</li>
+ * <li><strong>TABLE_CATALOG</strong> String => catalog name
+ * (may be <code>null</code>)</li>
+ * </ol>
+ *
+ * @param catalog catalog name used to narrow down the search; ""
+ * means no catalog, <code>null</code> means any catalog
+ * @param schemaPattern schema name used to narrow down the
+ * search, <code>null</code> means schema name should not be used
+ * to narrow down search
+ * @return a <code>ResultSet</code> object in which each row is a
+ * schema description
+ * @exception SQLException if a database error occurs
+ */
+ public ResultSet getSchemas(String catalog, String schemaPattern)
+ throws SQLException
+ {
+ try {
+ synchronized (connection_) {
+ if (agent_.loggingEnabled()) {
+ agent_.logWriter_.traceEntry(this, "getSchemas");
+ }
+ return getSchemasX(catalog, schemaPattern);
+ }
+ } catch (SqlException se) {
+ throw se.getSQLException();
+ }
+ }
+
+ /**
+ * Untraced version of <code>getSchemas(String, String)</code>.
+ *
+ * @param catalog catalog name
+ * @param schemaPattern pattern for schema name
+ * @return a <code>ResultSet</code> value
+ * @exception SqlException if a database error occurs
+ * @see #getSchemas(String, String)
+ */
+ private ResultSet getSchemasX(String catalog, String schemaPattern)
+ throws SqlException
+ {
+ checkForClosedConnectionX();
+
+ // If the server has not implemented support for JDBC 4.0,
+ // SYSIBM.SQLTABLES does not recognize the GETSCHEMAS=2
+ // option, and it will call getTables() instead of
+ // getSchemas(). Therefore, check server version and throw an
+ // exception if the server does not support JDBC 4.0.
+ checkServerJdbcVersionX("getSchemas(String, String)", 4, 0);
+
+ String call = "SYSIBM.SQLTABLES(?, ?, '', '', 'GETSCHEMAS=2')";
+ PreparedStatement cs = prepareMetaDataQuery(call);
+ if (catalog == null) {
+ cs.setNullX(1, java.sql.Types.VARCHAR);
+ } else {
+ cs.setStringX(1, catalog);
+ }
+ if (schemaPattern == null) {
+ cs.setNullX(2, java.sql.Types.VARCHAR);
+ } else {
+ cs.setStringX(2, schemaPattern);
+ }
+ return cs.executeQueryX();
+ }
+
+ /**
+ * Returns a list of the client info properties supported by the
+ * driver. The result set contains the following columns:
+ *
+ * <p>
+ * <ol>
+ * <li>NAME String=> The name of the client info property.</li>
+ * <li>MAX_LEN int=> The maximum length of the value for the
+ * property.</li>
+ * <li>DEFAULT_VALUE String=> The default value of the property.</li>
+ * <li>DESCRIPTION String=> A description of the property.</li>
+ * </ol>
+ *
+ * <p>The <code>ResultSet</code> is sorted by the NAME column.
+ *
+ * @return A <code>ResultSet</code> object; each row is a
+ * supported client info property
+ * @exception SQLException if an error occurs
+ */
+ public ResultSet getClientInfoProperties() throws SQLException {
+ try {
+ synchronized (connection_) {
+ if (agent_.loggingEnabled()) {
+ agent_.logWriter_.traceEntry(this,
+ "getClientInfoProperties");
+ }
+ return getClientInfoPropertiesX();
+ }
+ } catch (SqlException se) {
+ throw se.getSQLException();
+ }
+ }
+
+ /**
+ * Untraced version of <code>getClientInfoProperties()</code>.
+ * Returns an empty <code>ResultSet</code> with the correct column
+ * names.
+ *
+ * @return a <code>ResultSet</code> value
+ * @exception SqlException if a database error occurs
+ * @see #getClientInfoProperties
+ */
+ private ResultSet getClientInfoPropertiesX() throws SqlException {
+ checkForClosedConnectionX();
+ final String sql =
+ "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";
+ PreparedStatement ps = connection_.prepareDynamicCatalogQuery(sql);
+ return ps.executeQueryX();
+ }
+
//----------------------------helper methods----------------------------------
Modified: db/derby/code/trunk/java/client/org/apache/derby/client/net/NetDatabaseMetaData40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/client/net/NetDatabaseMetaData40.java?rev=395561&r1=395560&r2=395561&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/net/NetDatabaseMetaData40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/net/NetDatabaseMetaData40.java Thu Apr 20 04:15:20 2006
@@ -48,15 +48,6 @@
return RowIdLifetime.ROWID_UNSUPPORTED;
}
- public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
- throw SQLExceptionFactory.notImplemented ("getSchemas (String, String)");
- }
-
- public ResultSet getClientInfoProperties()
- throws SQLException {
- throw SQLExceptionFactory.notImplemented ("getClientInfoProperties ()");
- }
-
/**
* Returns false unless <code>interfaces</code> is implemented
*
Modified: db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java?rev=395561&r1=395560&r2=395561&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/catalog/SystemProcedures.java Thu Apr 20 04:15:20 2006
@@ -231,20 +231,29 @@
}
/**
- * Map SQLTables to EmbedDatabaseMetaData.getSchemas, getCatalogs, getTableTypes and getTables
+ * Map SQLTables to EmbedDatabaseMetaData.getSchemas, getCatalogs,
+ * getTableTypes and getTables, and return the result of the
+ * DatabaseMetaData calls.
+ *
+ * <p>JCC and DNC overload this method:
+ * <ul>
+ * <li>If options contains the string 'GETSCHEMAS=1',
+ * call getSchemas()</li>
+ * <li>If options contains the string 'GETSCHEMAS=2',
+ * call getSchemas(String, String)</li>
+ * <li>If options contains the string 'GETCATALOGS=1',
+ * call getCatalogs()</li>
+ * <li>If options contains the string 'GETTABLETYPES=1',
+ * call getTableTypes()</li>
+ * <li>otherwise, call getTables()</li>
+ * </ul>
*
- * containing the result of the DatabaseMetaData calls
* @param catalogName SYSIBM.SQLTables CatalogName varchar(128),
* @param schemaName SYSIBM.SQLTables SchemaName varchar(128),
* @param tableName SYSIBM.SQLTables TableName varchar(128),
* @param tableType SYSIBM.SQLTables TableType varchar(4000))
* @param options SYSIBM.SQLTables Options varchar(4000))
* @param rs output parameter, the resultset object
- * JCC overloads this method:
- * If options contains the string 'GETSCHEMAS=1', call getSchemas
- * If options contains the string 'GETCATALOGS=1', call getCatalogs
- * If options contains the string 'GETTABLETYPES=1', call getTableTypes
- * otherwise, call getTables
*/
public static void SQLTABLES (String catalogName, String schemaName, String tableName,
String tableType, String options, ResultSet[] rs)
@@ -264,10 +273,17 @@
return;
}
optionValue = getOption("GETSCHEMAS", options);
- if (optionValue != null && optionValue.trim().equals("1"))
- {
- rs[0] = getDMD().getSchemas();
- return;
+ if (optionValue != null) {
+ optionValue = optionValue.trim();
+ if (optionValue.equals("1")) {
+ rs[0] = getDMD().getSchemas();
+ return;
+ }
+ if (optionValue.equals("2")) {
+ EmbedDatabaseMetaData edmd = (EmbedDatabaseMetaData) getDMD();
+ rs[0] = edmd.getSchemas(catalogName, schemaName);
+ return;
+ }
}
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=395561&r1=395560&r2=395561&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 Thu Apr 20 04:15:20 2006
@@ -3217,6 +3217,68 @@
return getSimpleQuery("getAttributes");
}
+ /////////////////////////////////////////////////////////////////////////
+ //
+ // JDBC 4.0 - New public methods
+ //
+ /////////////////////////////////////////////////////////////////////////
+
+ /**
+ * JDBC 4.0
+ *
+ * <p>Returns a list of the client info properties supported by
+ * the driver. The result set contains the following columns:
+ *
+ * <p>
+ * <ol>
+ * <li>NAME String=> The name of the client info property.</li>
+ * <li>MAX_LEN int=> The maximum length of the value for the
+ * property.</li>
+ * <li>DEFAULT_VALUE String=> The default value of the property.</li>
+ * <li>DESCRIPTION String=> A description of the property.</li>
+ * </ol>
+ *
+ * <p>The <code>ResultSet</code> is sorted by the NAME column.
+ *
+ * @return A <code>ResultSet</code> object; each row is a
+ * supported client info property
+ * @exception SQLException if an error occurs
+ */
+ public ResultSet getClientInfoProperties() throws SQLException {
+ return getSimpleQuery("getClientInfoProperties");
+ }
+
+ /**
+ * JDBC 4.0
+ *
+ * <p>Get the schema names available in this database. The results
+ * are ordered by schema name.
+ *
+ * <p>The schema columns are:
+ * <ol>
+ * <li><strong>TABLE_SCHEM</strong> String => schema name</li>
+ * <li><strong>TABLE_CATALOG</strong> String => catalog name
+ * (may be <code>null</code>)</li>
+ * </ol>
+ *
+ * @param catalog catalog name used to narrow down the search; ""
+ * means no catalog, <code>null</code> means any catalog
+ * @param schemaPattern schema name used to narrow down the
+ * search, <code>null</code> means schema name should not be used
+ * to narrow down search
+ * @return a <code>ResultSet</code> object in which each row is a
+ * schema description
+ * @exception SQLException if a database error occurs
+ */
+ public ResultSet getSchemas(String catalog, String schemaPattern)
+ throws SQLException
+ {
+ PreparedStatement s = getPreparedQuery("getSchemasWithParams");
+ s.setString(1, swapNull(catalog));
+ s.setString(2, swapNull(schemaPattern));
+ return s.executeQuery();
+ }
+
//////////////////////////////////////////////////////////////
//
// MISC
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=395561&r1=395560&r2=395561&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 Thu Apr 20 04:15:20 2006
@@ -42,15 +42,6 @@
return RowIdLifetime.ROWID_UNSUPPORTED;
}
-
- public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
- PreparedStatement s = getPreparedQuery("getSchemasWithParams");
- s.setString(1, swapNull(catalog));
- s.setString(2, swapNull(schemaPattern));
- return s.executeQuery();
- }
-
-
public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
return true;
}
@@ -58,10 +49,6 @@
public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
// TODO - find out what this really should be
return false;
- }
-
- public ResultSet getClientInfoProperties() throws SQLException {
- return getSimpleQuery("getClientInfoProperties");
}
public boolean providesQueryObjectGenerator() throws SQLException {
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/metadata.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/metadata.out?rev=395561&r1=395560&r2=395561&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/metadata.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/metadata.out Thu Apr 20 04:15:20 2006
@@ -30,6 +30,31 @@
SYSIBM
SYSPROC
SYSSTAT
+getSchemas(String, String):
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+NULLID,null
+SQLJ,null
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
getCatalogs():
TABLE_CAT[CHAR]
getSearchStringEscape():
@@ -114,6 +139,8 @@
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
getUDTs() with user-named types in ('JAVA_OBJECT', 'STRUCT') :
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
+getClientInfoProperties():
+NAME[VARCHAR],MAX_LEN[INTEGER],DEFAULT_VALUE[VARCHAR],DESCRIPTION[VARCHAR]
allProceduresAreCallable(): true
getUserName(): APP
isReadOnly(): false
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/metadata.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/metadata.out?rev=395561&r1=395560&r2=395561&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/metadata.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/metadata.out Thu Apr 20 04:15:20 2006
@@ -30,6 +30,31 @@
SYSIBM
SYSPROC
SYSSTAT
+getSchemas(String, String):
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+NULLID,null
+SQLJ,null
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
getCatalogs():
TABLE_CAT[CHAR]
getSearchStringEscape():
@@ -114,6 +139,8 @@
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
getUDTs() with user-named types in ('JAVA_OBJECT', 'STRUCT') :
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
+getClientInfoProperties():
+NAME[VARCHAR],MAX_LEN[INTEGER],DEFAULT_VALUE[VARCHAR],DESCRIPTION[VARCHAR]
allProceduresAreCallable(): true
getUserName(): APP
isReadOnly(): false
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/odbc_metadata.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/odbc_metadata.out?rev=395561&r1=395560&r2=395561&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/odbc_metadata.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/odbc_metadata.out Thu Apr 20 04:15:20 2006
@@ -60,6 +60,31 @@
SYSIBM
SYSPROC
SYSSTAT
+getSchemas(String, String):
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+NULLID,null
+SQLJ,null
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
getCatalogs():
TABLE_CAT[CHAR]
getSearchStringEscape():
@@ -144,6 +169,8 @@
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
getUDTs() with user-named types in ('JAVA_OBJECT', 'STRUCT') :
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
+getClientInfoProperties():
+NAME[VARCHAR],MAX_LEN[INTEGER],DEFAULT_VALUE[VARCHAR],DESCRIPTION[VARCHAR]
allProceduresAreCallable(): true
getUserName(): APP
isReadOnly(): false
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out?rev=395561&r1=395560&r2=395561&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/Upgrade_10_1_10_2.out Thu Apr 20 04:15:20 2006
@@ -34,6 +34,7 @@
SYSIBM
SYSPROC
SYSSTAT
+DatabaseMetaData.getSchemas(String, String) is not available.
getCatalogs():
TABLE_CAT[CHAR]
getSearchStringEscape():
@@ -58,6 +59,7 @@
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
getUDTs() with user-named types in ('JAVA_OBJECT', 'STRUCT') :
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
+DatabaseMetaData.getClientInfoProperties() is not available.
allProceduresAreCallable(): true
getUserName(): APP
isReadOnly(): false
@@ -718,6 +720,31 @@
SYSIBM
SYSPROC
SYSSTAT
+getSchemas(String, String):
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+NULLID,null
+SQLJ,null
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
getCatalogs():
TABLE_CAT[CHAR]
getSearchStringEscape():
@@ -802,6 +829,8 @@
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
getUDTs() with user-named types in ('JAVA_OBJECT', 'STRUCT') :
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
+getClientInfoProperties():
+NAME[VARCHAR],MAX_LEN[INTEGER],DEFAULT_VALUE[VARCHAR],DESCRIPTION[VARCHAR]
allProceduresAreCallable(): true
getUserName(): APP
isReadOnly(): false
@@ -1423,6 +1452,7 @@
SYSIBM
SYSPROC
SYSSTAT
+DatabaseMetaData.getSchemas(String, String) is not available.
getCatalogs():
TABLE_CAT[CHAR]
getSearchStringEscape():
@@ -1447,6 +1477,7 @@
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
getUDTs() with user-named types in ('JAVA_OBJECT', 'STRUCT') :
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
+DatabaseMetaData.getClientInfoProperties() is not available.
allProceduresAreCallable(): true
getUserName(): APP
isReadOnly(): false
@@ -2106,6 +2137,31 @@
SYSIBM
SYSPROC
SYSSTAT
+getSchemas(String, String):
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+NULLID,null
+SQLJ,null
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
getCatalogs():
TABLE_CAT[CHAR]
getSearchStringEscape():
@@ -2190,6 +2246,8 @@
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
getUDTs() with user-named types in ('JAVA_OBJECT', 'STRUCT') :
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
+getClientInfoProperties():
+NAME[VARCHAR],MAX_LEN[INTEGER],DEFAULT_VALUE[VARCHAR],DESCRIPTION[VARCHAR]
allProceduresAreCallable(): true
getUserName(): APP
isReadOnly(): false
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/metadata.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/metadata.out?rev=395561&r1=395560&r2=395561&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/metadata.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/metadata.out Thu Apr 20 04:15:20 2006
@@ -30,6 +30,31 @@
SYSIBM
SYSPROC
SYSSTAT
+getSchemas(String, String):
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+NULLID,null
+SQLJ,null
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
getCatalogs():
TABLE_CAT[CHAR]
getSearchStringEscape():
@@ -114,6 +139,8 @@
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
getUDTs() with user-named types in ('JAVA_OBJECT', 'STRUCT') :
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
+getClientInfoProperties():
+NAME[VARCHAR],MAX_LEN[INTEGER],DEFAULT_VALUE[VARCHAR],DESCRIPTION[VARCHAR]
allProceduresAreCallable(): true
getUserName(): APP
isReadOnly(): false
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/odbc_metadata.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/odbc_metadata.out?rev=395561&r1=395560&r2=395561&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/odbc_metadata.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/odbc_metadata.out Thu Apr 20 04:15:20 2006
@@ -60,6 +60,31 @@
SYSIBM
SYSPROC
SYSSTAT
+getSchemas(String, String):
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+NULLID,null
+SQLJ,null
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+SYS,null
+SYSCAT,null
+SYSCS_DIAG,null
+SYSCS_UTIL,null
+SYSFUN,null
+SYSIBM,null
+SYSPROC,null
+SYSSTAT,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
+APP,null
+TABLE_SCHEM[VARCHAR],TABLE_CATALOG[VARCHAR]
getCatalogs():
TABLE_CAT[CHAR]
getSearchStringEscape():
@@ -144,6 +169,8 @@
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
getUDTs() with user-named types in ('JAVA_OBJECT', 'STRUCT') :
TYPE_CAT[CHAR],TYPE_SCHEM[CHAR],TYPE_NAME[VARCHAR],CLASS_NAME[LONG VARCHAR],DATA_TYPE[INTEGER],REMARKS[CHAR]
+getClientInfoProperties():
+NAME[VARCHAR],MAX_LEN[INTEGER],DEFAULT_VALUE[VARCHAR],DESCRIPTION[VARCHAR]
allProceduresAreCallable(): true
getUserName(): APP
isReadOnly(): false
Modified: 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=395561&r1=395560&r2=395561&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/TestDbMetaData.java Thu Apr 20 04:15:20 2006
@@ -91,13 +91,7 @@
"return false");
}
- try {
- checkEmptyRS(met.getClientInfoProperties());
- } catch (SQLException e) {
- // TODO: remove try/catch once method is implemented!
- System.out.println("getClientInfoProperties():");
- dumpSQLExceptions(e);
- }
+ checkEmptyRS(met.getClientInfoProperties());
// Make sure the constants provided in JDBC40Translation is correct
@@ -165,33 +159,16 @@
// Dump return value for all DUMMY functions
dumpRS(met.getFunctionParameters(null,null,"DUMMY%",""));
-
- try {
- //
- // 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"));
- } catch (SQLException e) {
- // TODO: remove try/catch once method is implemented!
- System.out.println("getSchemas():");
- dumpSQLExceptions(e);
- }
+
+ // 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"));
t_wrapper(met);
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/metadata_test.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/metadata_test.java?rev=395561&r1=395560&r2=395561&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/metadata_test.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/metadata_test.java Thu Apr 20 04:15:20 2006
@@ -38,8 +38,12 @@
import java.util.Properties;
import java.util.StringTokenizer;
+import java.lang.reflect.Method;
+
import org.apache.derby.tools.ij;
import org.apache.derbyTesting.functionTests.util.TestUtil;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Modifier;
/**
* Test of database meta-data. This program simply calls each of the meta-data
@@ -400,6 +404,8 @@
System.out.println("getSchemas():");
dumpRS(met.getSchemas());
+ testGetSchemasWithTwoParams(met);
+
System.out.println();
System.out.println("getCatalogs():");
dumpRS(met.getCatalogs());
@@ -518,6 +524,8 @@
userNamedTypes[1] = java.sql.Types.STRUCT;
dumpRS(met.getUDTs("a", null, null, userNamedTypes));
+ testGetClientInfoProperties(met);
+
/*
* any methods that were not tested above using code written
* specifically for it will now be tested in a generic way.
@@ -1384,6 +1392,84 @@
}
+ /**
+ * Run tests for <code>getSchemas()</code> with two
+ * parameters. (New method introduced by JDBC 4.0.)
+ *
+ * @param dmd a <code>DatabaseMetaData</code> object
+ */
+ private void testGetSchemasWithTwoParams(DatabaseMetaData dmd) {
+ // not implemented in JCC
+ if (TestUtil.isJCCFramework()) return;
+
+ Class[] paramTypes = { String.class, String.class };
+
+ Method method = null;
+ try {
+ method = dmd.getClass().getMethod("getSchemas", paramTypes);
+ } catch (NoSuchMethodException nsme) { }
+
+ if (method == null || Modifier.isAbstract(method.getModifiers())) {
+ System.out.println("DatabaseMetaData.getSchemas(String, String) " +
+ "is not available.");
+ return;
+ }
+
+ System.out.println();
+ System.out.println("getSchemas(String, String):");
+
+ // array of argument lists
+ String[][] args = {
+ // no qualifiers
+ { null, null },
+ // wildcard
+ { null, "SYS%" },
+ // exact match
+ { null, "APP" },
+ // no match
+ { null, "BLAH" },
+ };
+
+ for (int i = 0; i < args.length; ++i) {
+ try {
+ dumpRS((ResultSet) method.invoke(dmd, args[i]));
+ } catch (Exception e) {
+ dumpAllExceptions(e);
+ }
+ }
+ }
+
+ /**
+ * Run tests for <code>getClientInfoProperties()</code> introduced
+ * by JDBC 4.0.
+ *
+ * @param dmd a <code>DatabaseMetaData</code> object
+ */
+ private void testGetClientInfoProperties(DatabaseMetaData dmd) {
+ // not implemented in JCC
+ if (TestUtil.isJCCFramework()) return;
+
+ Method method = null;
+ try {
+ method = dmd.getClass().getMethod("getClientInfoProperties", null);
+ } catch (NoSuchMethodException nsme) {}
+
+ if (method == null || Modifier.isAbstract(method.getModifiers())) {
+ System.out.println("DatabaseMetaData.getClientInfoProperties() " +
+ "is not available.");
+ return;
+ }
+
+ System.out.println();
+ System.out.println("getClientInfoProperties():");
+
+ try {
+ dumpRS((ResultSet) method.invoke(dmd, null));
+ } catch (Exception e) {
+ dumpAllExceptions(e);
+ }
+ }
+
static private void showSQLExceptions (SQLException se) {
while (se != null) {
System.out.println("SQLSTATE("+se.getSQLState()+"): " + se.getMessage());
@@ -1399,6 +1485,25 @@
se = se.getNextException();
}
}
+
+ /**
+ * Print the entire exception chain.
+ *
+ * @param t a <code>Throwable</code>
+ */
+ private static void dumpAllExceptions(Throwable t) {
+ System.out.println("FAIL -- unexpected exception");
+ do {
+ t.printStackTrace(System.out);
+ if (t instanceof SQLException) {
+ t = ((SQLException) t).getNextException();
+ } else if (t instanceof InvocationTargetException) {
+ t = ((InvocationTargetException) t).getTargetException();
+ } else {
+ break;
+ }
+ } while (t != null);
+ }
/**
* This method is responsible for executing a metadata query and returning