📄 simpletextdatabasemetadata.java
字号:
} //----------------------------------------------------------------------- // getMaxStatements - JDBC API // How many active statements can we have open at one time to this // database? //----------------------------------------------------------------------- public int getMaxStatements() throws SQLException { // The SimpleText driver does not have a limit. 0 indicates no // limit, or the limit is not known. return 0; } //----------------------------------------------------------------------- // getMaxTableNameLength - JDBC API // What's the maximum length of a table name? //----------------------------------------------------------------------- public int getMaxTableNameLength() throws SQLException { return SimpleTextDefine.MAX_TABLE_NAME_LEN; } //----------------------------------------------------------------------- // getMaxTablesInSelect - JDBC API // What's the maximum number of tables in a SELECT? //----------------------------------------------------------------------- public int getMaxTablesInSelect() throws SQLException { // The SimpleText driver does not support joins, so only 1 table // is allowed to be specified in a SELECT statement return 1; } //----------------------------------------------------------------------- // getMaxUserNameLength - JDBC API // What's the maximum length of a user name? //----------------------------------------------------------------------- public int getMaxUserNameLength() throws SQLException { // The SimpleText driver does not support users return 0; } //----------------------------------------------------------------------- // getDefaultTransactionIsolation - JDBC API // What's the database's default transaction isolation level? The // values are defined in java.sql.Connection. //----------------------------------------------------------------------- public int getDefaultTransactionIsolation() throws SQLException { // The SimpleText driver does not support transactions return Connection.TRANSACTION_NONE; } //----------------------------------------------------------------------- // supportsTransactions - JDBC API // Are transactions supported? If not, commit is a noop and the // isolation level is TRANSACTION_NONE. //----------------------------------------------------------------------- public boolean supportsTransactions() throws SQLException { // The SimpleText driver does not support transactions return false; } //----------------------------------------------------------------------- // supportsTransactionIsolationLevel - JDBC API // Does the database support the given transaction isolation level? // // level the values are defined in java.sql.Connection //----------------------------------------------------------------------- public boolean supportsTransactionIsolationLevel( int level) throws SQLException { // The SimpleText driver does not support transaction. Return // false for any level except for TRANSACTION_NONE boolean rc = false; if (level == Connection.TRANSACTION_NONE) { rc = true; } return rc; } //----------------------------------------------------------------------- // supportsDataDefinitionAndDataManipulationTransactions - JDBC API // Are both data definition and data manipulation statements // within a transaction supported? //----------------------------------------------------------------------- public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException { // The SimpleText driver does not support transactions return false; } //----------------------------------------------------------------------- // supportsDataManipulationTransactionsOnly // Are only data manipulation statements within a transaction // supported? //----------------------------------------------------------------------- public boolean supportsDataManipulationTransactionsOnly() throws SQLException { // The SimpleText driver does not support transactions return false; } //----------------------------------------------------------------------- // dataDefinitionsCausesTransactionCommit - JDBC API // Does a data definition statement within a transaction force the // transaction to commit? //----------------------------------------------------------------------- public boolean dataDefinitionCausesTransactionCommit() throws SQLException { // The SimpleText driver does not support transactions return false; } //----------------------------------------------------------------------- // dataDefinitionIgnoredInTransactions - JDBC API // Is a data definition statement within a transaction ignored? //----------------------------------------------------------------------- public boolean dataDefinitionIgnoredInTransactions() throws SQLException { // The SimpleText driver does not support transactions return false; } //----------------------------------------------------------------------- // getProcedures - JDBC API // Get a description of stored procedures available in a // catalog. // // Only procedure descriptions matching the schema and // procedure name criteria are returned. They are ordered by // PROCEDURE_SCHEM, and PROCEDURE_NAME. // // Each procedure description has the the following columns: // // (1) PROCEDURE_CAT String => procedure catalog (may be null) // (2) PROCEDURE_SCHEM String => procedure schema (may be null) // (3) PROCEDURE_NAME String => procedure name // (4) REMARKS String => explanatory comment on the procedure // (5) PROCEDURE_TYPE short => kind of procedure: // procedureResultUnknown - May return a result // procedureNoResult - Does not return a result // procedureReturnsResult - Returns a result // // catalog a catalog name; "" retrieves those without a catalog // schemaPattern a schema name pattern; "" retrieves those // without a schema // procedureNamePattern a procedure name pattern // // Returns a ResultSet. Each row is a procedure description //----------------------------------------------------------------------- public ResultSet getProcedures( String catalog, String schemaPattern, String procedureNamePattern) throws SQLException { if (traceOn()) { trace("@getProcedures(" + catalog + ", " + schemaPattern + ", " + procedureNamePattern + ")"); } // The SimpleText driver does not support procedures. Instead of // throwing a 'Driver not capable' SQLException, we'll be // graceful and return an empty result set SimpleTextStatement stmt = (SimpleTextStatement) ownerConnection.createStatement(); // Create a Hashtable for all of the columns Hashtable columns = new Hashtable(); add(columns, 1, "PROCEDURE_CAT", Types.VARCHAR); add(columns, 2, "PROCEDURE_SCHEM", Types.VARCHAR); add(columns, 3, "PROCEDURE_NAME", Types.VARCHAR); add(columns, 4, "REMARKS", Types.VARCHAR); add(columns, 5, "PROCEDURE_TYPE", Types.SMALLINT); // Create an empty Hashtable for the rows Hashtable rows = new Hashtable(); // Create the ResultSet object and return it SimpleTextResultSet rs = new SimpleTextResultSet(); rs.initialize(stmt, columns, rows); return rs; } //----------------------------------------------------------------------- // getProcedureColumns - JDBC API // Get a description of a catalog's stored procedure parameters // and result columns. // // Only descriptions matching the schema, procedure and // parameter name criteria are returned. They are ordered by // PROCEDURE_SCHEM and PROCEDURE_NAME. Within this, the return value, // if any, is first. Next are the parameter descriptions in call // order. The column descriptions follow in column number order. // // Each row in the ResultSet is a parameter desription or // column description with the following fields: // // (1) PROCEDURE_CAT String => procedure catalog (may be null) // (2) PROCEDURE_SCHEM String => procedure schema (may be null) // (3) PROCEDURE_NAME String => procedure name // (4) COLUMN_NAME String => column/parameter name // (5) COLUMN_TYPE Short => kind of column/parameter: // procedureColumnUnknown - nobody knows // procedureColumnIn - IN parameter // procedureColumnInOut - INOUT parameter // procedureColumnOut - OUT parameter // procedureColumnReturn - procedure return value // procedureColumnResult - result column in ResultSet // (6) DATA_TYPE short => SQL type from java.sql.Types // (7) TYPE_NAME String => SQL type name // (8) PRECISION int => precision // (9) LENGTH int => length in bytes of data // (10) SCALE short => scale // (11) RADIX short => radix // (12) NULLABLE short => can it contain NULL? // procedureNoNulls - does not allow NULL values // procedureNullable - allows NULL values // procedureNullableUnknown - nullability unknown // (13) REMARKS String => comment describing parameter/column // // Note: Some databases may not return the column // descriptions for a procedure. Additional columns beyond // REMARKS can be defined by the database. // // catalog a catalog name; "" retrieves those without a catalog // schemaPattern a schema name pattern; "" retrieves those // without a schema // procedureNamePattern a procedure name pattern // columnNamePattern a column name pattern // // Returns a ResultSet. Each row is a stored procedure parameter or // column description //----------------------------------------------------------------------- public ResultSet getProcedureColumns( String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException { if (traceOn()) { trace("@getProcedureColumns(" + catalog + ", " + schemaPattern + ", " + procedureNamePattern + ", " + columnNamePattern + ")"); } // The SimpleText driver does not support procedures. Instead of // throwing a 'Driver not capable' SQLException, we'll be // graceful and return an empty result set SimpleTextStatement stmt = (SimpleTextStatement) ownerConnection.createStatement(); // Create a Hashtable for all of the columns Hashtable columns = new Hashtable(); add(columns, 1, "PROCEDURE_CAT", Types.VARCHAR); add(columns, 2, "PROCEDURE_SCHEM", Types.VARCHAR); add(columns, 3, "PROCEDURE_NAME", Types.VARCHAR); add(columns, 4, "COLUMN_NAME", Types.VARCHAR); add(columns, 5, "COLUMN_TYPE", Types.SMALLINT); add(columns, 6, "DATA_TYPE", Types.SMALLINT); add(columns, 7, "TYPE_NAME", Types.VARCHAR); add(columns, 8, "PRECISION", Types.INTEGER); add(columns, 9, "LENGTH", Types.INTEGER); add(columns, 10, "LENGTH", Types.SMALLINT); add(columns, 11, "RADIX", Types.SMALLINT); add(columns, 12, "NULLABLE", Types.SMALLINT); add(columns, 13, "REMARKS", Types.VARCHAR); // Create an empty Hashtable for the rows Hashtable rows = new Hashtable(); // Create the ResultSet object and return it SimpleTextResultSet rs = new SimpleTextResultSet(); rs.initialize(stmt, columns, rows); return rs; } //----------------------------------------------------------------------- // getTables - JDBC API // Get a description of tables available in a catalog. // // Only table descriptions matching the catalog, schema, table // name and type criteria are returned. They are ordered by // TABLE_TYPE, TABLE_SCHEM and TABLE_NAME. // // Each table description has the following columns: // // (1) TABLE_CAT String => table catalog (may be null) // (2) TABLE_SCHEM String => table schema (may be null) // (3) TABLE_NAME String => table name // (4) TABLE_TYPE String => table type. // Typical types are "TABLE", "VIEW", "SYSTEM TABLE", // "GLOBAL TEMPORARY", "LOCAL TEMPORARY", "ALIAS", "SYNONYM" // (5) REMARKS String => explanatory comment on the table // // Note: Some databases may not return information for // all tables. // // catalog a catalog name; "" retrieves those without a catalog // schemaPattern a schema name pattern; "" retrieves those // without a schema // tableNamePattern a table name pattern // types a list of table types to include; null returns all // types // // Returns a ResultSet. Each row is a table description //----------------------------------------------------------------------- public ResultSet getTables( String catalog, String schemaPattern, String tableNamePattern, String types[]) throws SQLException { if (traceOn()) { trace("@getTables(" + catalog + ", " + schemaPattern + ", " + tableNamePattern + ")"); } // Create a statement object SimpleTextStatement stmt
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -