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

📄 jtdsdatabasemetadata.java

📁 第三方的SQL Server and Sybase的jdbc dirver,速度更快
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        rsTmp.moveToInsertRow();        while (rs.next()) {            for (int i = 1; i <= colCnt; i++) {                rsTmp.updateObject(i, rs.getObject(i));            }            rsTmp.insertRow();        }        rs.close();        rsTmp.moveToCurrentRow();        rsTmp.setConcurrency(ResultSet.CONCUR_READ_ONLY);        return rsTmp;    }    //----------------------------------------------------------------------    // The following group of methods exposes various limitations    // based on the target database with the current driver.    // Unless otherwise specified, a result of zero means there is no    // limit, or the limit is not known.    /**     * How many hex characters can you have in an inline binary literal?     *     * @return max literal length     * @throws SQLException if a database-access error occurs.     */    public int getMaxBinaryLiteralLength() throws SQLException {        // Sybase jConnect says 255        // Actual value is 16384 for Sybase 12.5        // MS JDBC says 0        // Probable maximum size for MS is 65,536 * network packet size        return 131072;        // per "Programming ODBC for SQLServer" Appendix A    }    /**     * What's the maximum length of a catalog name?     *     * @return max name length in bytes     * @throws SQLException if a database-access error occurs.     */    public int getMaxCatalogNameLength() throws SQLException {        return sysnameLength;    }    /**     * What's the max length for a character literal?     *     * @return max literal length     * @throws SQLException if a database-access error occurs.     */    public int getMaxCharLiteralLength() throws SQLException {        // Sybase jConnect says 255        // Actual value is 16384 for Sybase 12.5        // MS JDBC says 0        // Probable maximum size for MS is 65,536 * network packet size        return 131072;        // per "Programming ODBC for SQLServer" Appendix A    }    /**     * What's the limit on column name length?     *     * @return max literal length     * @throws SQLException if a database-access error occurs.     */    public int getMaxColumnNameLength() throws SQLException {        // per "Programming ODBC for SQLServer" Appendix A        return sysnameLength;    }    /**     * What's the maximum number of columns in a "GROUP BY" clause?     *     * @return max number of columns     * @throws SQLException if a database-access error occurs.     */    public int getMaxColumnsInGroupBy() throws SQLException {        // Sybase jConnect says 16        // MS JDBC says 16        // per "Programming ODBC for SQLServer" Appendix A        // Actual MS value is 8060 / average bytes per column        return (tdsVersion >= Driver.TDS70) ? 0 : 16;    }    /**     * What's the maximum number of columns allowed in an index?     *     * @return max columns     * @throws SQLException if a database-access error occurs.     */    public int getMaxColumnsInIndex() throws SQLException {        // per SQL Server Books Online "Administrator's Companion",        // Part 1, Chapter 1.        // Sybase 12.5 is 31        return 16;    }    /**     * What's the maximum number of columns in an "ORDER BY" clause?     *     * @return max columns     * @throws SQLException if a database-access error occurs.     */    public int getMaxColumnsInOrderBy() throws SQLException {        // per "Programming ODBC for SQLServer" Appendix A        // Sybase 12.5 is 31        // Actual MS value is 8060 / average bytes per column        return (tdsVersion >= Driver.TDS70) ? 0 : 16;    }    /**     * What's the maximum number of columns in a "SELECT" list?     *     * @return max columns     * @throws SQLException if a database-access error occurs.     */    public int getMaxColumnsInSelect() throws SQLException {        // Sybase jConnect says 0        // per "Programming ODBC for SQLServer" Appendix A        return 4096;    }    /**     * What's the maximum number of columns in a table?     *     * @return max columns     * @throws SQLException if a database-access error occurs.     */    public int getMaxColumnsInTable() throws SQLException {        // Sybase jConnect says 250        // per "Programming ODBC for SQLServer" Appendix A        // MS 2000 should be 4096        // Sybase 12.5 is now 1024        return (tdsVersion >= Driver.TDS70) ? 1024 : 250;    }    /**     * How many active connections can we have at a time to this database?     *     * @return max connections     * @throws SQLException if a database-access error occurs.     */    public int getMaxConnections() throws SQLException {        // Sybase - could query syscurconfigs to get actual value        // which in practice will be a lot less than 32767!        // per SQL Server Books Online "Administrator's Companion",        // Part 1, Chapter 1.        return 32767;    }    /**     * What's the maximum cursor name length?     *     * @return max cursor name length in bytes     * @throws SQLException if a database-access error occurs.     */    public int getMaxCursorNameLength() throws SQLException {        // per "Programming ODBC for SQLServer" Appendix A        return sysnameLength;    }    /**     * What's the maximum length of an index (in bytes)?     *     * @return max index length in bytes     * @throws SQLException if a database-access error occurs.     */    public int getMaxIndexLength() throws SQLException {        // Sybase JConnect says 255        // Actual Sybase 12.5 is 600 - 5300 depending on page size        // per "Programming ODBC for SQLServer" Appendix A        return (tdsVersion >= Driver.TDS70) ? 900 : 255;    }    /**     * What's the maximum length of a procedure name?     *     * @return max name length in bytes     * @throws SQLException if a database-access error occurs.     */    public int getMaxProcedureNameLength() throws SQLException {        // per "Programming ODBC for SQLServer" Appendix A        return sysnameLength;    }    /**     * What's the maximum length of a single row?     *     * @return max row size in bytes     * @throws SQLException if a database-access error occurs.     */    public int getMaxRowSize() throws SQLException {        // Sybase jConnect says 1962 but this can be more with wide tables.        // per SQL Server Books Online "Administrator's Companion",        // Part 1, Chapter 1.        return (tdsVersion >= Driver.TDS70) ? 8060 : 1962;    }    /**     * What's the maximum length allowed for a schema name?     *     * @return max name length in bytes     * @throws SQLException if a database-access error occurs.     */    public int getMaxSchemaNameLength() throws SQLException {        return sysnameLength;    }    /**     * What's the maximum length of a SQL statement?     *     * @return max length in bytes     * @throws SQLException if a database-access error occurs.     */    public int getMaxStatementLength() throws SQLException {        // I think this should return 0 (no limit)        // actual limit for SQL 7/2000 is 65536 * packet size!        // Sybase JConnect says 0        // MS JDBC says 0        // per "Programming ODBC for SQLServer" Appendix A        return 0;    }    /**     * How many active statements can we have open at one time to this     * database?     *     * @return the maximum     * @throws SQLException if a database-access error occurs.     */    public int getMaxStatements() throws SQLException {        return 0;    }    /**     * What's the maximum length of a table name?     *     * @return max name length in bytes     * @throws SQLException if a database-access error occurs.     */    public int getMaxTableNameLength() throws SQLException {        // per "Programming ODBC for SQLServer" Appendix A        return sysnameLength;    }    /**     * What's the maximum number of tables in a SELECT?     *     * @return the maximum     * @throws SQLException if a database-access error occurs.     */    public int getMaxTablesInSelect() throws SQLException {        // Sybase JConnect says 256        // MS JDBC says 32!        // Actual Sybase 12.5 is 50        // per "Programming ODBC for SQLServer" Appendix A        return (tdsVersion > Driver.TDS50) ? 256 : 16;    }    /**     *   What's the maximum length of a user name?     *     * @return max name length in bytes     * @throws SQLException if a database-access error occurs.     */    public int getMaxUserNameLength() throws SQLException {        return sysnameLength;    }    /**     * Get a comma separated list of math functions.     *     * @return the list     * @throws SQLException if a database-access error occurs.     */    public String getNumericFunctions() throws SQLException {        // I don't think either Sybase or SQL have a truncate maths function        // so I have removed it from the list.        // Also all other drivers return this list in lower case. Should we?        return "abs,acos,asin,atan,atan2,ceiling,cos,cot,degrees,exp,floor,log,"            + "log10,mod,pi,power,radians,rand,round,sign,sin,sqrt,tan";    }    /**     * Get a description of a table's primary key columns. They are ordered by     * COLUMN_NAME. <P>     *     * Each primary key column 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>COLUMN_NAME</B> String =>column name     *   <LI> <B>KEY_SEQ</B> short =>sequence number within primary key     *   <LI> <B>PK_NAME</B> String =>primary key name (may be null)     * </OL>     *     * @param catalog a catalog name; "" retrieves those without a     *        <code>null</code> means drop catalog name from the selection criteria     * @param schema a schema name; "" retrieves those without a schema     * @param table a table name     * @return ResultSet - each row is a primary key column description     * @throws SQLException if a database-access error occurs.     */    public java.sql.ResultSet getPrimaryKeys(String catalog,                                             String schema,                                             String table)    throws SQLException {        String colNames[] = {"TABLE_CAT",    "TABLE_SCHEM",                             "TABLE_NAME",   "COLUMN_NAME",                             "KEY_SEQ",      "PK_NAME"};        int    colTypes[] = {Types.VARCHAR,  Types.VARCHAR,                             Types.VARCHAR,  Types.VARCHAR,                             Types.SMALLINT, Types.VARCHAR};        String query = "sp_pkeys ?, ?, ?";        CallableStatement s = connection.prepareCall(syscall(catalog, query));        s.setString(1, table);

⌨️ 快捷键说明

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