📄 simpletextdatabasemetadata.java
字号:
//----------------------------------------------------------------------------//// Module: SimpleTextDatabaseMetaData.java//// Description: Implementation of the JDBC DatabaseMetaData interface//// Author: Karl Moss//// Copyright: (C) 1996,1997 Karl Moss. All rights reserved.// You may study, use, modify and distribute this example// for any purpose, provided that this copyright notice// appears in all copies. This example is provided WITHOUT// WARRANTY either expressed or implied.//----------------------------------------------------------------------------package jdbc.SimpleText;//---------------------------------------------------------------------------// This class provides information about the database as a whole.//// Many of the methods here return lists of information in ResultSets.// You can use the normal ResultSet methods such as getString and getInt// to retrieve the data from these ResultSets. If a given form of// metadata is not available, these methods show throw a SQLException.//// Some of these methods take arguments that are String patterns. These// methods all have names such as fooPattern. Within a pattern String "%"// means match any substring of 0 or more characters and "_" means match// any one character.//---------------------------------------------------------------------------// NOTE - this is an implementation of the JDBC API version 1.20//---------------------------------------------------------------------------import java.sql.*;import java.util.Hashtable;public class SimpleTextDatabaseMetaData extends SimpleTextObject implements DatabaseMetaData{ //------------------------------------------------------------------------ // initialize //------------------------------------------------------------------------ public void initialize( SimpleTextIConnection con) throws SQLException { // Save the owning connection object ownerConnection = con; } //----------------------------------------------------------------------- // allProceduresAreCallable - JDBC API // Can all the procedures returned by getProcedures be called by the // current user? //----------------------------------------------------------------------- public boolean allProceduresAreCallable() throws SQLException { // The SimpleText driver does not support callable statements, so // none are callable return false; } //----------------------------------------------------------------------- // allTablesAreSelectable - JDBC API // Can all the tables returned by getTable be SELECTed by the // current user? //----------------------------------------------------------------------- public boolean allTablesAreSelectable() throws SQLException { // The SimpleText driver allows all tables returned by getTables // to be selected return true; } //----------------------------------------------------------------------- // getURL - JDBC API // What's the url for this database? // Return the url or null if it can't be generated //----------------------------------------------------------------------- public String getURL() throws SQLException { // Can't generate a URL return null; } //----------------------------------------------------------------------- // getUserName - JDBC API // What's our user name as known to the database? //----------------------------------------------------------------------- public String getUserName() throws SQLException { // The SimpleText driver does not support user names return ""; } //----------------------------------------------------------------------- // isReadOnly - JDBC API // Is the database in read-only mode? //----------------------------------------------------------------------- public boolean isReadOnly() throws SQLException { return ownerConnection.isReadOnly(); } //----------------------------------------------------------------------- // nullsAreSortedHigh - JDBC API // Are NULL values sorted high? //----------------------------------------------------------------------- public boolean nullsAreSortedHigh() throws SQLException { // The SimpleText driver does not support nulls (or sorting, for // that matter) return false; } //----------------------------------------------------------------------- // nullsAreSortedLow - JDBC API // Are NULL values sorted low? //----------------------------------------------------------------------- public boolean nullsAreSortedLow() throws SQLException { // The SimpleText driver does not support nulls (or sorting, for // that matter) return false; } //----------------------------------------------------------------------- // nullsAreSortedAtStart - JDBC API // Are NULL values sorted at the start regardless of sort order? //----------------------------------------------------------------------- public boolean nullsAreSortedAtStart() throws SQLException { // The SimpleText driver does not support nulls (or sorting, for // that matter) return false; } //----------------------------------------------------------------------- // nullsAreSortedAtEnd - JDBC API // Are NULL values sorted at the end regardless of sort order? //----------------------------------------------------------------------- public boolean nullsAreSortedAtEnd() throws SQLException { // The SimpleText driver does not support nulls (or sorting, for // that matter) return false; } //----------------------------------------------------------------------- // getDatabaseProductName - JDBC API // What's the name of this database product? //----------------------------------------------------------------------- public String getDatabaseProductName() throws SQLException { return "Simple Text JDBC Driver"; } //----------------------------------------------------------------------- // getDatabaseProductVersion - JDBC API // What's the version of this database product? //----------------------------------------------------------------------- public String getDatabaseProductVersion() throws SQLException { return "1.00"; } //----------------------------------------------------------------------- // getDriverName - JDBC API // What's the name of this JDBC driver? //----------------------------------------------------------------------- public String getDriverName() throws SQLException { return "SimpleText"; } //----------------------------------------------------------------------- // getDriverVersion - JDBC API // What's the version of this JDBC driver? //----------------------------------------------------------------------- public String getDriverVersion() throws SQLException { String s = ""; int minorVersion = getDriverMinorVersion(); // Format the minor version to have 4 places, with leading 0's if (minorVersion < 1000) s += "0"; if (minorVersion < 100) s += "0"; if (minorVersion < 10) s += "0"; s += "" + minorVersion; return "" + getDriverMajorVersion() + "." + s; } //----------------------------------------------------------------------- // getDriverMajorVersion - JDBC API // What's this JDBC driver's major version number? //----------------------------------------------------------------------- public int getDriverMajorVersion() { return SimpleTextDefine.MAJOR_VERSION; } //----------------------------------------------------------------------- // getDriverMinorVersion - JDBC API // What's this JDBC driver's minor version number? //----------------------------------------------------------------------- public int getDriverMinorVersion() { return SimpleTextDefine.MINOR_VERSION; } //----------------------------------------------------------------------- // usesLocalFiles - JDBC API // Does the database store tables in a local file? //----------------------------------------------------------------------- public boolean usesLocalFiles() throws SQLException { // The SimpleText driver stores all database data in files return true; } //----------------------------------------------------------------------- // usesLocalFilePerTable - JDBC API // Does the database use a file for each table? //----------------------------------------------------------------------- public boolean usesLocalFilePerTable() throws SQLException { // The SimpleText driver uses a file for each table return true; } //----------------------------------------------------------------------- // supportsMixedCaseIdentifiers - JDBC API // Does the database support mixed case unquoted SQL identifiers? //----------------------------------------------------------------------- public boolean supportsMixedCaseIdentifiers() throws SQLException { return true; } //----------------------------------------------------------------------- // storesUpperCaseIdentifiers - JDBC API // Does the database store mixed case unquoted SQL identifiers in // upper case? //----------------------------------------------------------------------- public boolean storesUpperCaseIdentifiers() throws SQLException { return true; } //----------------------------------------------------------------------- // storesLowerCaseIdentifiers - JDBC API // Does the database store mixed case unquoted SQL identifiers in // lower case? //----------------------------------------------------------------------- public boolean storesLowerCaseIdentifiers() throws SQLException { return false; } //----------------------------------------------------------------------- // storesMixedCaseIdentifiers - JDBC API // Does the database store mixed case unquoted SQL identifiers in // mixed case? //----------------------------------------------------------------------- public boolean storesMixedCaseIdentifiers() throws SQLException { return false; } //----------------------------------------------------------------------- // supportsMixedCaseQuotedIdentifiers - JDBC API // Does the database support mixed case quoted SQL identifiers? // // A JDBC compliant driver will always return true. //----------------------------------------------------------------------- public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException { return true; } //----------------------------------------------------------------------- // storesUpperCaseQuotedIdentifiers - JDBC API // Does the database store mixed case quoted SQL identifiers in // upper case? // // A JDBC compliant driver will always return true. //----------------------------------------------------------------------- public boolean storesUpperCaseQuotedIdentifiers() throws SQLException { return true; } //----------------------------------------------------------------------- // storesLowerCaseQuotedIdentifiers - JDBC API // Does the database store mixed case quoted SQL identifiers in // lower case? // // A JDBC compliant driver will always return false. //----------------------------------------------------------------------- public boolean storesLowerCaseQuotedIdentifiers() throws SQLException { return false; } //----------------------------------------------------------------------- // storesMixedCaseQuotedIdentifiers - JDBC API // Does the database store mixed case quoted SQL identifiers in // mixed case? // // A JDBC compliant driver will always return false. //----------------------------------------------------------------------- public boolean storesMixedCaseQuotedIdentifiers() throws SQLException { return false; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -