databasemetadata.java
来自「derby database source code.good for you.」· Java 代码 · 共 1,768 行 · 第 1/5 页
JAVA
1,768 行
} } private ResultSet getProcedureColumnsX(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SqlException { checkForClosedConnection(); ; PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLPROCEDURECOLS(?,?,?,?,?)"); cs.setStringX(1, catalog); cs.setStringX(2, schemaPattern); cs.setStringX(3, procedureNamePattern); cs.setStringX(4, columnNamePattern); cs.setStringX(5, getOptions()); lastGetProcedureColumnsResultSet_ = executeCatalogQuery(cs); return lastGetProcedureColumnsResultSet_; } // call stored procedure SQLTables // SYSIBM.SQLTables( // CatalogName varchar(128), // SchemaName varchar(128), // TableName varchar(128), // TaleType varchar(4000), // Options varchar(4000)) // public java.sql.ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types[]) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getTables", catalog, schemaPattern, tableNamePattern, types); } return getTablesX(catalog, schemaPattern, tableNamePattern, types); } } private ResultSet getTablesX(String catalog, String schemaPattern, String tableNamePattern, String types[]) throws SqlException { checkForClosedConnection(); PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLTABLES(?,?,?,?,?)"); 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); } if (tableNamePattern == null) { cs.setNullX(3, java.sql.Types.VARCHAR); } else { cs.setStringX(3, tableNamePattern); } String tableTypes = new String(); int i = 0; if (types == null) { cs.setNullX(4, java.sql.Types.VARCHAR); } else if (types.length == 1 && (types[0].trim()).equals("%")) { cs.setStringX(4, types[0]); } else { while (i < types.length) { if (i > 0) { tableTypes = tableTypes.concat(","); } tableTypes = tableTypes.concat("'" + types[i] + "'"); i++; } cs.setStringX(4, tableTypes); } cs.setStringX(5, getOptions()); lastGetTablesResultSet_ = executeCatalogQuery(cs); return lastGetTablesResultSet_; } // call stored procedure SQLTables // SYSIBM.SQLTables( // CatalogName varchar(128), // SchemaName varchar(128), // TableName varchar(128), // TaleType varchar(4000), // Options varchar(4000)) // public java.sql.ResultSet getSchemas() throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getSchemas"); } return getSchemasX(); } } private ResultSet getSchemasX() throws SqlException { checkForClosedConnection(); ; PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')"); return (ResultSet) cs.executeQueryX(); } // DERBY does not have the notion of a catalog, so we return a result set with no rows. public java.sql.ResultSet getCatalogs() throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getCatalogs"); } return getCatalogsX(); } } private ResultSet getCatalogsX() throws SqlException { checkForClosedConnection(); PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLTABLES('', '', '', '', 'GETCATALOGS=1')"); return (ResultSet) cs.executeQueryX(); } // call stored procedure SQLTables // SYSIBM.SQLTables( // CatalogName varchar(128), // SchemaName varchar(128), // TableName varchar(128), // TableType varchar(4000), // Options varchar(4000)) public java.sql.ResultSet getTableTypes() throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getTableTypes"); } return getTableTypesX(); } } private ResultSet getTableTypesX() throws SqlException { checkForClosedConnection(); ; PreparedStatement cs = null; cs = prepareMetaDataQuery("SYSIBM.SQLTABLES(?,?,?,?,?)"); cs.setStringX(1, ""); cs.setStringX(2, ""); cs.setStringX(3, ""); cs.setStringX(4, "%"); int cursorHold; if (connection_.holdability() == ClientDataSource.HOLD_CURSORS_OVER_COMMIT) { cursorHold = 1; } else { cursorHold = 0; } cs.setStringX(5, "DATATYPE='JDBC';GETTABLETYPES=1; CURSORHOLD=" + cursorHold); lastGetTablesResultSet_ = executeCatalogQuery(cs); return lastGetTablesResultSet_; } // call stored procedure SQLColumns // SYSIBM.SQLColumns( // CatalogName varchar(128), // SchemaName varchar(128), // TableName varchar(128), // ColumnName varchar(128), // Options varchar(4000)) // public java.sql.ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getColumns", catalog, schemaPattern, tableNamePattern, columnNamePattern); } checkForClosedConnection(); return getColumnsX(catalog, schemaPattern, tableNamePattern, columnNamePattern); } } private ResultSet getColumnsX(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SqlException { checkForClosedConnection(); PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLCOLUMNS(?,?,?,?,?)"); cs.setStringX(1, catalog); cs.setStringX(2, schemaPattern); cs.setStringX(3, tableNamePattern); cs.setStringX(4, columnNamePattern); //Always null for JDBC cs.setStringX(5, getOptions()); lastGetColumnsResultSet_ = executeCatalogQuery(cs); return lastGetColumnsResultSet_; } // call stored procedure SQLColumnPrivileges // SYSIBM.SQLColPrivileges( // CatalogName varchar(128), // SchemaName varchar(128), // TableName varchar(128), // ColumnName varchar(128), // Options varchar(4000)) // public java.sql.ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getColumnPrivileges", catalog, schema, table, columnNamePattern); } return getColumnPrivilegesX(catalog, schema, table, columnNamePattern); } } private ResultSet getColumnPrivilegesX(String catalog, String schema, String table, String columnNamePattern) throws SqlException { checkForClosedConnection(); // check input params, table and columnNamePattern cannot be null if (table == null) { throw new SqlException(agent_.logWriter_, "getColumnPrivileges(): null not allowed for table name"); } PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLCOLPRIVILEGES(?,?,?,?,?)"); cs.setStringX(1, catalog); cs.setStringX(2, schema); cs.setStringX(3, table); cs.setStringX(4, columnNamePattern); cs.setStringX(5, getOptions()); lastGetColumnPrivilegesResultSet_ = executeCatalogQuery(cs); return lastGetColumnPrivilegesResultSet_; } // call stored procedure SQLTablePrivileges // SYSIBM.SQLTablePrivileges( // CatalogName varchar(128), // SchemaName varchar(128), // TableName varchar(128), // Options varchar(4000)) // public java.sql.ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getTablePrivileges", catalog, schemaPattern, tableNamePattern); } return getTablePrivilegesX(catalog, schemaPattern, tableNamePattern); } } private ResultSet getTablePrivilegesX(String catalog, String schemaPattern, String tableNamePattern) throws SqlException { checkForClosedConnection(); ; PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLTABLEPRIVILEGES(?,?,?,?)"); cs.setStringX(1, catalog); cs.setStringX(2, schemaPattern); cs.setStringX(3, tableNamePattern); cs.setStringX(4, getOptions()); lastGetTablePrivilegesResultSet_ = executeCatalogQuery(cs); return lastGetTablePrivilegesResultSet_; } // call stored procedure // SYSIBM.SQLSPECIALCOLUMNS ( IN COLTYPE SMALLINT, // IN CATALOG_NAME VARCHAR(128), // IN SCHEMA_NAME VARCHAR(128), // IN TABLE_NAME VARCHAR(128), // IN SCOPE SMALLINT, // IN NULLABLE SMALLINT, // IN OPTIONS VARCHAR(4000) ) // public java.sql.ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getBestRowIdentifier", catalog, schema, table, scope, nullable); } return getBestRowIdentifierX(catalog, schema, table, scope, nullable); } } private ResultSet getBestRowIdentifierX(String catalog, String schema, String table, int scope, boolean nullable) throws SqlException { checkForClosedConnection(); ; // check input params // // validate input table, which can not be null if (table == null) { throw new SqlException(agent_.logWriter_, "getBestRowIdentifier(): null not allowed for table name"); } PreparedStatement cs = prepareMetaDataQuery("SYSIBM.SQLSPECIALCOLUMNS(?,?,?,?,?,?,?)"); cs.setIntX(1, SQL_BEST_ROWID); cs.setStringX(2, catalog); cs.setStringX(3, schema); cs.setStringX(4, table); cs.setIntX(5, scope); if (nullable) { cs.setShortX(6, (short) 1); } else { cs.setShortX(6, (short) 0); } cs.setStringX(7, getOptions()); lastGetSpecialColumnsResultSet_ = executeCatalogQuery(cs); return lastGetSpecialColumnsResultSet_; } public java.sql.ResultSet getVersionColumns(String catalog, String schema, String table) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getVersionColumns", catalog, schema, table); } return getVersionColumnsX(catalog, schema, table); } } private ResultSet getVersionColumnsX(String catalog,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?