⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 databasemetadata.java

📁 关系型数据库 Postgresql 6.5.2
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
package postgresql.jdbc1;// IMPORTANT NOTE: This file implements the JDBC 1 version of the driver.// If you make any modifications to this file, you must make sure that the// changes are also made (if relevent) to the related JDBC 2 class in the// postgresql.jdbc2 package.import java.sql.*;import java.util.*;import postgresql.Field;/** * This class provides information about the database as a whole. * * <p>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 should throw a SQLException. * * <p>Some of these methods take arguments that are String patterns.  These * arguments 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.  Only metadata entries matching the search * pattern are returned.  if a search pattern argument is set to a null * ref, it means that argument's criteria should be dropped from the * search. * * <p>A SQLException will be throws if a driver does not support a meta * data method.  In the case of methods that return a ResultSet, either * a ResultSet (which may be empty) is returned or a SQLException is * thrown. * * @see java.sql.DatabaseMetaData */public class DatabaseMetaData implements java.sql.DatabaseMetaData {  Connection connection;		// The connection association    // These define various OID's. Hopefully they will stay constant.  static final int iVarcharOid = 1043;	// OID for varchar  static final int iBoolOid = 16;	// OID for bool  static final int iInt2Oid = 21;	// OID for int2  static final int iInt4Oid = 23;	// OID for int4  static final int VARHDRSZ =  4;	// length for int4    // This is a default value for remarks  private static final byte defaultRemarks[]="no remarks".getBytes();    public DatabaseMetaData(Connection conn)  {    this.connection = conn;  }    /**   * Can all the procedures returned by getProcedures be called   * by the current user?   *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean allProceduresAreCallable() throws SQLException  {    return true;		// For now...  }    /**   * Can all the tables returned by getTable be SELECTed by   * the current user?   *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean allTablesAreSelectable() throws SQLException  {    return true;		// For now...  }    /**   * What is the URL for this database?   *   * @return the url or null if it cannott be generated   * @exception SQLException if a database access error occurs   */  public String getURL() throws SQLException  {    return connection.getURL();  }    /**   * What is our user name as known to the database?   *   * @return our database user name   * @exception SQLException if a database access error occurs   */  public String getUserName() throws SQLException  {    return connection.getUserName();  }    /**   * Is the database in read-only mode?   *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean isReadOnly() throws SQLException  {    return connection.isReadOnly();  }    /**   * Are NULL values sorted high?   *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean nullsAreSortedHigh() throws SQLException  {    return false;  }    /**   * Are NULL values sorted low?   *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean nullsAreSortedLow() throws SQLException  {    return false;  }    /**   * Are NULL values sorted at the start regardless of sort order?   *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean nullsAreSortedAtStart() throws SQLException  {    return false;  }    /**   * Are NULL values sorted at the end regardless of sort order?   *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean nullsAreSortedAtEnd() throws SQLException  {    return true;  }    /**   * What is the name of this database product - we hope that it is   * PostgreSQL, so we return that explicitly.   *   * @return the database product name   * @exception SQLException if a database access error occurs   */  public String getDatabaseProductName() throws SQLException  {    return new String("PostgreSQL");  }    /**   * What is the version of this database product.   *   * <p>Note that PostgreSQL 6.3 has a system catalog called pg_version -    * however, select * from pg_version on any database retrieves   * no rows.   *   * <p>For now, we will return the version 6.3 (in the hope that we change   * this driver as often as we change the database)   *   * @return the database version   * @exception SQLException if a database access error occurs   */  public String getDatabaseProductVersion() throws SQLException  {    return ("6.4");  }    /**   * What is the name of this JDBC driver?  If we don't know this   * we are doing something wrong!   *   * @return the JDBC driver name   * @exception SQLException why?   */  public String getDriverName() throws SQLException  {    return new String("PostgreSQL Native Driver");  }    /**   * What is the version string of this JDBC driver?  Again, this is   * static.   *   * @return the JDBC driver name.   * @exception SQLException why?   */  public String getDriverVersion() throws SQLException  {    return new String(Integer.toString(connection.this_driver.getMajorVersion())+"."+Integer.toString(connection.this_driver.getMinorVersion()));  }    /**   * What is this JDBC driver's major version number?   *   * @return the JDBC driver major version   */  public int getDriverMajorVersion()  {    return connection.this_driver.getMajorVersion();  }    /**   * What is this JDBC driver's minor version number?   *   * @return the JDBC driver minor version   */  public int getDriverMinorVersion()  {    return connection.this_driver.getMinorVersion();  }    /**   * Does the database store tables in a local file?  No - it   * stores them in a file on the server.   *    * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean usesLocalFiles() throws SQLException  {    return false;  }    /**   * Does the database use a file for each table?  Well, not really,   * since it doesnt use local files.    *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean usesLocalFilePerTable() throws SQLException  {    return false;  }    /**   * Does the database treat mixed case unquoted SQL identifiers   * as case sensitive and as a result store them in mixed case?   * A JDBC-Compliant driver will always return false.   *   * <p>Predicament - what do they mean by "SQL identifiers" - if it   * means the names of the tables and columns, then the answers   * given below are correct - otherwise I don't know.   *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean supportsMixedCaseIdentifiers() throws SQLException  {    return false;  }    /**   * Does the database treat mixed case unquoted SQL identifiers as   * case insensitive and store them in upper case?   *   * @return true if so   */  public boolean storesUpperCaseIdentifiers() throws SQLException  {    return false;  }    /**   * Does the database treat mixed case unquoted SQL identifiers as   * case insensitive and store them in lower case?   *   * @return true if so   */  public boolean storesLowerCaseIdentifiers() throws SQLException  {    return true;  }    /**   * Does the database treat mixed case unquoted SQL identifiers as   * case insensitive and store them in mixed case?   *   * @return true if so   */  public boolean storesMixedCaseIdentifiers() throws SQLException  {    return false;  }    /**   * Does the database treat mixed case quoted SQL identifiers as   * case sensitive and as a result store them in mixed case?  A   * JDBC compliant driver will always return true.    *   * <p>Predicament - what do they mean by "SQL identifiers" - if it   * means the names of the tables and columns, then the answers   * given below are correct - otherwise I don't know.   *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException  {    return true;  }    /**   * Does the database treat mixed case quoted SQL identifiers as   * case insensitive and store them in upper case?   *   * @return true if so   */  public boolean storesUpperCaseQuotedIdentifiers() throws SQLException  {    return false;  }    /**   * Does the database treat mixed case quoted SQL identifiers as case   * insensitive and store them in lower case?   *   * @return true if so   */  public boolean storesLowerCaseQuotedIdentifiers() throws SQLException  {    return false;  }    /**   * Does the database treat mixed case quoted SQL identifiers as case   * insensitive and store them in mixed case?   *   * @return true if so   */  public boolean storesMixedCaseQuotedIdentifiers() throws SQLException  {    return false;  }    /**   * What is the string used to quote SQL identifiers?  This returns   * a space if identifier quoting isn't supported.  A JDBC Compliant   * driver will always use a double quote character.   *   * <p>If an SQL identifier is a table name, column name, etc. then   * we do not support it.   *   * @return the quoting string   * @exception SQLException if a database access error occurs   */  public String getIdentifierQuoteString() throws SQLException  {    return null;  }    /**   * Get a comma separated list of all a database's SQL keywords that   * are NOT also SQL92 keywords.   *   * <p>Within PostgreSQL, the keywords are found in   * 	src/backend/parser/keywords.c   *   * <p>For SQL Keywords, I took the list provided at   * 	<a href="http://web.dementia.org/~shadow/sql/sql3bnf.sep93.txt">   * http://web.dementia.org/~shadow/sql/sql3bnf.sep93.txt</a>   * which is for SQL3, not SQL-92, but it is close enough for   * this purpose.   *   * @return a comma separated list of keywords we use   * @exception SQLException if a database access error occurs   */  public String getSQLKeywords() throws SQLException  {    return new String("abort,acl,add,aggregate,append,archive,arch_store,backward,binary,change,cluster,copy,database,delimiters,do,extend,explain,forward,heavy,index,inherits,isnull,light,listen,load,merge,nothing,notify,notnull,oids,purge,rename,replace,retrieve,returns,rule,recipe,setof,stdin,stdout,store,vacuum,verbose,version");  }    public String getNumericFunctions() throws SQLException  {    // XXX-Not Implemented    return "";  }    public String getStringFunctions() throws SQLException  {    // XXX-Not Implemented    return "";  }    public String getSystemFunctions() throws SQLException  {    // XXX-Not Implemented    return "";  }    public String getTimeDateFunctions() throws SQLException  {    // XXX-Not Implemented    return "";  }  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -