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

📄 jdbcdatabasemetadata.java

📁 非常棒的java数据库
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            prep.setString(1, getCatalogPattern(catalog));
            prep.setString(2, getSchemaPattern(schema));
            prep.setString(3, tableName);
            return prep.executeQuery();
        } catch (Throwable e) {
            throw logAndConvert(e);
        }
    }

    /**
     * Checks if all procedures callable.
     *
     * @return true
     */
    public boolean allProceduresAreCallable() {
        debugCodeCall("allProceduresAreCallable");
        return true;
    }

    /**
     * Checks if it possible to query all tables returned by getTables.
     *
     * @return true
     */
    public boolean allTablesAreSelectable() {
        debugCodeCall("allTablesAreSelectable");
        return true;
    }

    /**
     * Returns the database URL for this connection.
     *
     * @return the url
     */
    public String getURL() throws SQLException {
        try {
            debugCodeCall("getURL");
            return conn.getURL();
        } catch (Throwable e) {
            throw logAndConvert(e);
        }
    }

    /**
     * Returns the user name as passed to DriverManager.getConnection(url, user,
     * password).
     * 
     * @return the user name
     */
    public String getUserName() throws SQLException {
        try {
            debugCodeCall("getUserName");
            return conn.getUser();
        } catch (Throwable e) {
            throw logAndConvert(e);
        }
    }

    /**
     * Returns the same as Connection.isReadOnly().
     *
     * @return if read only optimization is switched on
     */
    public boolean isReadOnly() throws SQLException {
        try {
            debugCodeCall("isReadOnly");
            return conn.isReadOnly();
        } catch (Throwable e) {
            throw logAndConvert(e);
        }
    }

    /**
     * Checks is NULL values are sorted high (bigger than any non-null values).
     * 
     * @return false
     */
    public boolean nullsAreSortedHigh() {
        debugCodeCall("nullsAreSortedHigh");
        return false;
    }

    /**
     * Checks is NULL values are sorted low (smaller than any non-null values).
     *
     * @return true
     */
    public boolean nullsAreSortedLow() {
        debugCodeCall("nullsAreSortedLow");
        return true;
    }

    /**
     * Checks is NULL values are sorted at the beginning (no matter if ASC or
     * DESC is used).
     * 
     * @return false
     */
    public boolean nullsAreSortedAtStart() {
        debugCodeCall("nullsAreSortedAtStart");
        return false;
    }

    /**
     * Checks is NULL values are sorted at the end (no matter if ASC or DESC is
     * used).
     * 
     * @return false
     */
    public boolean nullsAreSortedAtEnd() {
        debugCodeCall("nullsAreSortedAtEnd");
        return false;
    }

    /**
     * Returns the connection that created this object.
     *
     * @return the connection
     */
    public Connection getConnection() {
        debugCodeCall("getConnection");
        return conn;
    }

    /**
     * Gets the list of procedures. The result set is sorted by PROCEDURE_SCHEM,
     * and PROCEDURE_NAME.
     * 
     * <ul>
     * <li>1 PROCEDURE_CAT (String) catalog </li>
     * <li>2 PROCEDURE_SCHEM (String) schema </li>
     * <li>3 PROCEDURE_NAME (String) name </li>
     * <li>4 NUM_INPUT_PARAMS (int) for future use, always 0 </li>
     * <li>5 NUM_OUTPUT_PARAMS (int) for future use, always 0 </li>
     * <li>6 NUM_RESULT_SETS (int) for future use, always 0 </li>
     * <li>7 REMARKS (String) description </li>
     * <li>8 PROCEDURE_TYPE (short) if this procedure returns a result
     * (procedureNoResult or procedureReturnsResult) </li>
     * </ul>
     * 
     * @return an empty result set
     * @throws SQLException if the connection is closed
     */
    public ResultSet getProcedures(String catalog, String schemaPattern,
            String procedureNamePattern) throws SQLException {
        try {
            if (debug()) {
                debugCode("getProcedures("
                        +quote(catalog)+", "
                        +quote(schemaPattern)+", "
                        +quote(procedureNamePattern)+");");
            }
            checkClosed();
            PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
                    + "ALIAS_CATALOG PROCEDURE_CAT, "
                    + "ALIAS_SCHEMA PROCEDURE_SCHEM, "
                    + "ALIAS_NAME PROCEDURE_NAME, "
                    + "ZERO() NUM_INPUT_PARAMS, "
                    + "ZERO() NUM_OUTPUT_PARAMS, "
                    + "ZERO() NUM_RESULT_SETS, "
                    + "REMARKS, "
                    + "RETURNS_RESULT PROCEDURE_TYPE "
                    + "FROM INFORMATION_SCHEMA.FUNCTION_ALIASES "
                    + "WHERE ALIAS_CATALOG LIKE ? "
                    + "AND ALIAS_SCHEMA LIKE ? "
                    + "AND ALIAS_NAME LIKE ? "
                    + "ORDER BY PROCEDURE_SCHEM, PROCEDURE_NAME");
            prep.setString(1, getCatalogPattern(catalog));
            prep.setString(2, getSchemaPattern(schemaPattern));
            prep.setString(3, getPattern(procedureNamePattern));
            return prep.executeQuery();
        } catch (Throwable e) {
            throw logAndConvert(e);
        }
    }

    /**
     * Gets the list of procedure columns.
     *
     * <ul>
     * <li>1 PROCEDURE_CAT (String) catalog
     * </li><li>2 PROCEDURE_SCHEM (String) schema
     * </li><li>3 PROCEDURE_NAME (String) name
     * </li><li>4 COLUMN_NAME (String) column name
     * </li><li>5 COLUMN_TYPE (short) column type
     * </li><li>6 DATA_TYPE (short) sql type
     * </li><li>7 TYPE_NAME (String) type name
     * </li><li>8 PRECISION (int) precision
     * </li><li>9 LENGTH (int) length
     * </li><li>10 SCALE (short) scale
     * </li><li>11 RADIX (int) always 10
     * </li><li>12 NULLABLE (short) nullable
     * </li><li>13 REMARKS (String) description
     * </li></ul>
     *
     * @throws SQLException if the connection is closed
     */
    public ResultSet getProcedureColumns(String catalog, String schemaPattern,
            String procedureNamePattern, String columnNamePattern)
            throws SQLException {
        try {
            if (debug()) {
                debugCode("getProcedureColumns("
                        +quote(catalog)+", "
                        +quote(schemaPattern)+", "
                        +quote(procedureNamePattern)+", "
                        +quote(columnNamePattern)+");");
            }
            checkClosed();
            PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
                    + "ALIAS_CATALOG PROCEDURE_CAT, "
                    + "ALIAS_SCHEMA PROCEDURE_SCHEM, "
                    + "ALIAS_NAME PROCEDURE_NAME, "
                    + "COLUMN_NAME, "
                    + "COLUMN_TYPE, "
                    + "DATA_TYPE, "
                    + "TYPE_NAME, "
                    + "PRECISION, "
                    + "PRECISION LENGTH, "
                    + "SCALE, "
                    + "RADIX, "
                    + "NULLABLE, "
                    + "REMARKS "
                    + "FROM INFORMATION_SCHEMA.FUNCTION_COLUMNS "
                    + "WHERE ALIAS_CATALOG LIKE ? "
                    + "AND ALIAS_SCHEMA LIKE ? "
                    + "AND ALIAS_NAME LIKE ? "
                    + "AND COLUMN_NAME LIKE ?");
            prep.setString(1, getCatalogPattern(catalog));
            prep.setString(2, getSchemaPattern(schemaPattern));
            prep.setString(3, getPattern(procedureNamePattern));
            prep.setString(4, getPattern(columnNamePattern));
            return prep.executeQuery();
        } catch (Throwable e) {
            throw logAndConvert(e);
        }
    }

    /**
     * Gets the list of schemas.
     * The result set is sorted by TABLE_SCHEM.
     *
     * <ul>
     * <li>1 TABLE_SCHEM (String) schema name
     * </li><li>2 TABLE_CATALOG (String) catalog name
     * </li><li>3 IS_DEFAULT (boolean) if this is the default schema
     * </li></ul>
     *
     * @return the schema list
     * @throws SQLException if the connection is closed
     */
    public ResultSet getSchemas() throws SQLException {
        try {
            debugCodeCall("getSchemas");
            checkClosed();
            PreparedStatement prep = conn
                    .prepareAutoCloseStatement("SELECT "
                            + "SCHEMA_NAME TABLE_SCHEM, "
                            + "CATALOG_NAME TABLE_CATALOG, "
                            +" IS_DEFAULT "
                            + "FROM INFORMATION_SCHEMA.SCHEMATA "
                            + "ORDER BY SCHEMA_NAME");
            return prep.executeQuery();
        } catch (Throwable e) {
            throw logAndConvert(e);
        }
    }

    /**
     * Gets the list of catalogs.
     * The result set is sorted by TABLE_CAT.
     *
     * <ul>
     * <li>1 TABLE_CAT (String) catalog name
     * </li></ul>
     *
     * @return the catalog list
     * @throws SQLException if the connection is closed
     */
    public ResultSet getCatalogs() throws SQLException {
        try {
            debugCodeCall("getCatalogs");
            checkClosed();
            PreparedStatement prep = conn.prepareAutoCloseStatement(
                    "SELECT CATALOG_NAME TABLE_CAT "
                    + "FROM INFORMATION_SCHEMA.CATALOGS");
            return prep.executeQuery();
        } catch (Throwable e) {
            throw logAndConvert(e);
        }
    }

    /**
     * Gets the list of table types. This call returns a result set with three
     * records: "SYSTEM TABLE", "TABLE", "and "VIEW".
     * The result set is sorted by TABLE_TYPE.
     *
     * <ul>
     * <li>1 TABLE_TYPE (String) table type
     * </li></ul>
     *
     * @return the table types
     * @throws SQLException if the connection is closed
     */
    public ResultSet getTableTypes() throws SQLException {
        try {
            debugCodeCall("getTableTypes");
            checkClosed();
            PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
                    + "TYPE TABLE_TYPE "
                    + "FROM INFORMATION_SCHEMA.TABLE_TYPES "
                    + "ORDER BY TABLE_TYPE");
            return prep.executeQuery();
        } catch (Throwable e) {
            throw logAndConvert(e);
        }
    }

    /**
     * Gets the list of column privileges. The result set is sorted by
     * COLUMN_NAME and PRIVILEGE
     * 
     * <ul>
     * <li>1 TABLE_CAT (String) table catalog </li>
     * <li>2 TABLE_SCHEM (String) table schema </li>
     * <li>3 TABLE_NAME (String) table name </li>
     * <li>4 COLUMN_NAME (String) column name </li>
     * <li>5 GRANTOR (String) grantor of access </li>
     * <li>6 GRANTEE (String) grantee of access </li>
     * <li>7 PRIVILEGE (String) SELECT, INSERT, UPDATE, DELETE or REFERENCES
     * (only one per row) </li>
     * <li>8 IS_GRANTABLE (String) YES means the grantee can grant access to
     * others </li>
     * </ul>
     * 
     * @param catalog null (to get all objects) or the catalog name
     * @param schema null (to get all objects) or a schema name (uppercase for
     *            unquoted names)
     * @param table a table name (uppercase for unquoted names)
     * @param columnNamePattern null (to get all objects) or a column name
     *            (uppercase for unquoted names)
     * @return the list of privileges
     * @throws SQLException if the connection is closed
     */
    public ResultSet getColumnPrivileges(String catalog, String schema,
            String table, String columnNamePattern) throws SQLException {
        try {
            if (debug()) {
                debugCode("getColumnPrivileges("
                        +quote(catalog)+", "
                        +quote(schema)+", "
                        +quote(table)+", "
                        +quote(columnNamePattern)+");");
            }
            checkClosed();
            PreparedStatement prep = conn.prepareAutoCloseStatement("SELECT "
                    + "TABLE_CATALOG TABLE_CAT, "
                    + "TABLE_SCHEMA TABLE_SCHEM, "
                    + "TABLE_NAME, "
                    + "COLUMN_NAME, "
                    + "GRANTOR, "

⌨️ 快捷键说明

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