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

📄 databasemetadata.java

📁 关系型数据库 Postgresql 6.5.2
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
  }    public int getMaxCatalogNameLength() throws SQLException  {    // XXX-Not Implemented    return 0;  }    /**   * What is the maximum length of a single row?  (not including   * blobs).  8192 is defined in PostgreSQL.   *   * @return max row size in bytes   * @exception SQLException if a database access error occurs   */  public int getMaxRowSize() throws SQLException  {    return 8192;  }    /**   * Did getMaxRowSize() include LONGVARCHAR and LONGVARBINARY   * blobs?  We don't handle blobs yet   *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean doesMaxRowSizeIncludeBlobs() throws SQLException  {    return false;  }    /**   * What is the maximum length of a SQL statement?   *   * @return max length in bytes   * @exception SQLException if a database access error occurs   */  public int getMaxStatementLength() throws SQLException  {    return 8192;  }    /**   * How many active statements can we have open at one time to   * this database?  Basically, since each Statement downloads   * the results as the query is executed, we can have many.  However,   * we can only really have one statement per connection going   * at once (since they are executed serially) - so we return   * one.   *   * @return the maximum   * @exception SQLException if a database access error occurs   */  public int getMaxStatements() throws SQLException  {    return 1;  }    /**   * What is the maximum length of a table name?  This was found   * from pg_class.relname length   *   * @return max name length in bytes   * @exception SQLException if a database access error occurs   */  public int getMaxTableNameLength() throws SQLException  {    return 32;  }    /**   * What is the maximum number of tables that can be specified   * in a SELECT?  Theoretically, this is the same number as the   * number of tables allowable.  In practice tho, it is much smaller   * since the number of tables is limited by the statement, we   * return 1024 here - this is just a number I came up with (being   * the number of tables roughly of three characters each that you   * can fit inside a 8192 character buffer with comma separators).   *   * @return the maximum   * @exception SQLException if a database access error occurs   */  public int getMaxTablesInSelect() throws SQLException  {    return 1024;  }    /**   * What is the maximum length of a user name?  Well, we generally   * use UNIX like user names in PostgreSQL, so I think this would   * be 8.  However, showing the schema for pg_user shows a length   * for username of 32.   *   * @return the max name length in bytes   * @exception SQLException if a database access error occurs   */  public int getMaxUserNameLength() throws SQLException  {    return 32;  }      /**   * What is the database's default transaction isolation level?  We   * do not support this, so all transactions are SERIALIZABLE.   *   * @return the default isolation level   * @exception SQLException if a database access error occurs   * @see Connection   */  public int getDefaultTransactionIsolation() throws SQLException  {    return Connection.TRANSACTION_SERIALIZABLE;  }    /**   * Are transactions supported?  If not, commit and rollback are noops   * and the isolation level is TRANSACTION_NONE.  We do support   * transactions.	   *   * @return true if transactions are supported   * @exception SQLException if a database access error occurs   */  public boolean supportsTransactions() throws SQLException  {    return true;  }    /**   * Does the database support the given transaction isolation level?   * We only support TRANSACTION_SERIALIZABLE   *    * @param level the values are defined in java.sql.Connection   * @return true if so   * @exception SQLException if a database access error occurs   * @see Connection   */  public boolean supportsTransactionIsolationLevel(int level) throws SQLException  {    if (level == Connection.TRANSACTION_SERIALIZABLE)      return true;    else      return false;  }    /**   * Are both data definition and data manipulation transactions    * supported?  I checked it, and could not do a CREATE TABLE   * within a transaction, so I am assuming that we don't   *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException  {    return false;  }    /**   * Are only data manipulation statements withing a transaction   * supported?   *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean supportsDataManipulationTransactionsOnly() throws SQLException  {    return true;  }    /**   * Does a data definition statement within a transaction force   * the transaction to commit?  I think this means something like:   *   * <p><pre>   * CREATE TABLE T (A INT);   * INSERT INTO T (A) VALUES (2);   * BEGIN;   * UPDATE T SET A = A + 1;   * CREATE TABLE X (A INT);   * SELECT A FROM T INTO X;   * COMMIT;   * </pre><p>   *   * does the CREATE TABLE call cause a commit?  The answer is no.     *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean dataDefinitionCausesTransactionCommit() throws SQLException  {    return false;  }    /**   * Is a data definition statement within a transaction ignored?   * It seems to be (from experiment in previous method)   *   * @return true if so   * @exception SQLException if a database access error occurs   */  public boolean dataDefinitionIgnoredInTransactions() throws SQLException  {    return true;  }    /**   * Get a description of stored procedures available in a catalog   *    * <p>Only procedure descriptions matching the schema and procedure   * name criteria are returned.  They are ordered by PROCEDURE_SCHEM   * and PROCEDURE_NAME   *   * <p>Each procedure description has the following columns:   * <ol>   * <li><b>PROCEDURE_CAT</b> String => procedure catalog (may be null)   * <li><b>PROCEDURE_SCHEM</b> String => procedure schema (may be null)   * <li><b>PROCEDURE_NAME</b> String => procedure name   * <li><b>Field 4</b> reserved (make it null)   * <li><b>Field 5</b> reserved (make it null)   * <li><b>Field 6</b> reserved (make it null)   * <li><b>REMARKS</b> String => explanatory comment on the procedure   * <li><b>PROCEDURE_TYPE</b> short => kind of procedure   *	<ul>   *    <li> procedureResultUnknown - May return a result   * 	<li> procedureNoResult - Does not return a result   *	<li> procedureReturnsResult - Returns a result   *    </ul>   * </ol>   *   * @param catalog - a catalog name; "" retrieves those without a   *	catalog; null means drop catalog name from criteria   * @param schemaParrern - a schema name pattern; "" retrieves those   *	without a schema - we ignore this parameter   * @param procedureNamePattern - a procedure name pattern   * @return ResultSet - each row is a procedure description   * @exception SQLException if a database access error occurs   */  public java.sql.ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException  {    // the field descriptors for the new ResultSet    Field f[] = new Field[8];    java.sql.ResultSet r;	// ResultSet for the SQL query that we need to do    Vector v = new Vector();		// The new ResultSet tuple stuff        byte remarks[] = defaultRemarks;        f[0] = new Field(connection, "PROCEDURE_CAT",   iVarcharOid, 32);    f[1] = new Field(connection, "PROCEDURE_SCHEM", iVarcharOid, 32);    f[2] = new Field(connection, "PROCEDURE_NAME",  iVarcharOid, 32);    f[3] = f[4] = f[5] = null;	// reserved, must be null for now    f[6] = new Field(connection, "REMARKS",	   iVarcharOid, 8192);    f[7] = new Field(connection, "PROCEDURE_TYPE", iInt2Oid,	2);        // If the pattern is null, then set it to the default    if(procedureNamePattern==null)      procedureNamePattern="%";        r = connection.ExecSQL("select proname, proretset from pg_proc where proname like '"+procedureNamePattern.toLowerCase()+"' order by proname");        while (r.next())      {	byte[][] tuple = new byte[8][0];		tuple[0] = null;			// Catalog name	tuple[1] = null;			// Schema name	tuple[2] = r.getBytes(1);		// Procedure name	tuple[3] = tuple[4] = tuple[5] = null;	// Reserved	tuple[6] = remarks;			// Remarks		if (r.getBoolean(2))	  tuple[7] = Integer.toString(java.sql.DatabaseMetaData.procedureReturnsResult).getBytes();	else	  tuple[7] = Integer.toString(java.sql.DatabaseMetaData.procedureNoResult).getBytes();		v.addElement(tuple);      }    return new ResultSet(connection, f, v, "OK", 1);  }    /**   * Get a description of a catalog's stored procedure parameters   * and result columns.   *   * <p>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.   *   * <p>Each row in the ResultSet is a parameter description or column    * description with the following fields:   * <ol>   * <li><b>PROCEDURE_CAT</b> String => procedure catalog (may be null)   * <li><b>PROCEDURE_SCHE</b>M String => procedure schema (may be null)   * <li><b>PROCEDURE_NAME</b> String => procedure name   * <li><b>COLUMN_NAME</b> String => column/parameter name   * <li><b>COLUMN_TYPE</b> Short => kind of column/parameter:   * <ul><li>procedureColumnUnknown - nobody knows   * <li>procedureColumnIn - IN parameter   * <li>procedureColumnInOut - INOUT parameter   * <li>procedureColumnOut - OUT parameter   * <li>procedureColumnReturn - procedure return value   * <li>procedureColumnResult - result column in ResultSet   * </ul>   * <li><b>DATA_TYPE</b> short => SQL type from java.sql.Types   * <li><b>TYPE_NAME</b> String => SQL type name   * <li><b>PRECISION</b> int => precision   * <li><b>LENGTH</b> int => length in bytes of data   * <li><b>SCALE</b> short => scale   * <li><b>RADIX</b> short => radix   * <li><b>NULLABLE</b> short => can it contain NULL?   * <ul><li>procedureNoNulls - does not allow NULL values   * <li>procedureNullable - allows NULL values   * <li>procedureNullableUnknown - nullability unknown   * <li><b>REMARKS</b> String => comment describing parameter/column   * </ol>   * @param catalog This is ignored in postgresql, advise this is set to null   * @param schemaPattern This is ignored in postgresql, advise this is set to null   * @param procedureNamePattern a procedure name pattern   * @param columnNamePattern a column name pattern   * @return each row is a stored procedure parameter or column description   * @exception SQLException if a database-access error occurs   * @see #getSearchStringEscape   */  // Implementation note: This is required for Borland's JBuilder to work  public java.sql.ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException  {    if(procedureNamePattern==null)      procedureNamePattern="%";        if(columnNamePattern==null)      columnNamePattern="%";        // for now, this returns an empty result set.    Field f[] = new Field[13];    ResultSet r;	// ResultSet for the SQL query that we need to do    Vector v = new Vector();		// The new ResultSet tuple stuff        f[0] = new Field(connection, new String("PROCEDURE_CAT"), iVarcharOid, 32);    f[1] = new Field(connection, new String("PROCEDURE_SCHEM"), iVarcharOid, 32);    f[2] = new Field(connection, new String("PROCEDURE_NAME"), iVarcharOid, 32);    f[3] = new Field(connection, new String("COLUMN_NAME"), iVarcharOid, 32);    f[4] = new Field(connection, new String("COLUMN_TYPE"), iInt2Oid, 2);    f[5] = new Field(connection, new String("DATA_TYPE"), iInt2Oid, 2);    f[6] = new Field(connection, new String("TYPE_NAME"), iVarcharOid, 32);    f[7] = new Field(connection, new String("PRECISION"), iInt4Oid, 4);    f[8] = new Field(connection, new String("LENGTH"), iInt4Oid, 4);    f[9] = new Field(connection, new String("SCALE"), iInt2Oid, 2);    f[10] = new Field(connection, new String("RADIX"), iInt2Oid, 2);    f[11] = new Field(connection, new String("NULLABLE"), iInt2Oid, 2);    f[12] = new Field(connection, new String("REMARKS"), iVarcharOid, 32);        // add query loop here        return new ResultSet(connection, f, v, "OK", 1);  }    /**   * Get a description of tables available in a catalog.                 *   * <p>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.                         *    * <p>Each table description has the following columns:        *   * <ol>   * <li><b>TABLE_CAT</b> String => table catalog (may be null)         * <li><b>TABLE_SCHEM</b> String => table schema (may be null)            * <li><b>TABLE_NAME</b> String => table name   * <li><b>TABLE_TYPE</b> String => table type. Typical types are "TABLE",   * "VIEW", "SYSTEM TABLE", "GLOBAL TEMPORARY", "LOCAL   * TEMPORARY", "ALIAS", "SYNONYM".                                * <li><b>REMARKS</b> String => explanatory comment on the table   * </ol>   *   * <p>The valid values for the types parameter are:   * "TABLE", "INDEX", "LARGE OBJECT", "SEQUENCE", "SYSTEM TABLE" and   * "SYSTEM INDEX"   *   * @param catalog a catalog name; For postgresql, this is ignored, and   * should be set to null   * @param schemaPattern a schema name pattern; For postgresql, this is ignored, and   * should be set to null   * @param tableNamePattern a table name pattern. For all tables this should be "%"   * @param types a list of table types to include; null returns   * all types   * @return each row is a table description         * @exception SQLException if a database-access error occurs.   */  public java.sql.ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types[]) throws SQLException  {    // Handle default value for types    if(types==null)      types = defaultTableTypes;        if(tableNamePattern==null)      tableNamePattern="%";        // the field descriptors for the new ResultSet    Field f[] = new Field[5];    java.sql.ResultSet r;	// ResultSet for the SQL query that we need to do    Vector v = new Vector();		// The new ResultSet tuple stuff        f[0] = new Field(connection, new String("TABLE_CAT"), iVarcharOid, 32);    f[1] = new Field(connection, new String("TABLE_SCHEM"), iVarcharOid, 32);    f[2] = new Field(connection, new String("TABLE_NAME"), iVarcharOid, 32);    f[3] = new Field(connection, new String("TABLE_TYPE"), iVarcharOid, 32);    f[4] = new Field(connection, new String("REMARKS"), iVarcharOid, 32);        // Now form the query

⌨️ 快捷键说明

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