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

📄 connection.java

📁 我费了好大劲才找到的一款非常全的OA办公自动化软件源码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        stmt.setResultSetConcurrency(resultSetConcurrency);        return stmt;    }    /**     * SQL statements without parameters are normally executed using Statement     * objects.  If the same SQL statement is executed many times, it is more     * efficient to use a PreparedStatement     *     * @return a new Statement object     *     * @throws SQLException passed through from the constructor     */    public java.sql.Statement createStatement() throws SQLException {        return createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY,            java.sql.ResultSet.CONCUR_READ_ONLY);    }    /**     * @see Connection#createStatement(int, int, int)     */    public java.sql.Statement createStatement(int resultSetType,        int resultSetConcurrency, int resultSetHoldability)        throws SQLException {        if (this.pedantic) {            if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT) {                throw new SQLException("HOLD_CUSRORS_OVER_COMMIT is only supported holdability level",                    SQLError.SQL_STATE_ILLEGAL_ARGUMENT);            }        }        return createStatement(resultSetType, resultSetConcurrency);    }    /**     * Cleanup the connection.     *     * @throws Throwable if an error occurs during cleanup.     */    protected void finalize() throws Throwable {        cleanup(null);    }    /**     * Is the server configured to use lower-case table names only?     *     * @return true if lower_case_table_names is 'on'     */    public boolean lowerCaseTableNames() {        return this.lowerCaseTableNames;    }    /**     * A driver may convert the JDBC sql grammar into its system's native SQL     * grammar prior to sending it; nativeSQL returns the native form of the     * statement that the driver would have sent.     *     * @param sql a SQL statement that may contain one or more '?' parameter     *        placeholders     *     * @return the native form of this statement     *     * @exception java.sql.SQLException if a database access error occurs     */    public String nativeSQL(String sql) throws java.sql.SQLException {        if (Driver.TRACE) {            Object[] args = { sql };            Debug.methodCall(this, "nativeSQL", args);            Debug.returnValue(this, "nativeSQL", sql);        }        return EscapeProcessor.escapeSQL(sql,            getIO().versionMeetsMinimum(4, 0, 2));    }    /**     * DOCUMENT ME!     *     * @return DOCUMENT ME!     */    public boolean parserKnowsUnicode() {        return this.parserKnowsUnicode;    }    /**     * DOCUMENT ME!     *     * @param sql DOCUMENT ME!     *     * @return DOCUMENT ME!     *     * @throws java.sql.SQLException DOCUMENT ME!     */    public java.sql.CallableStatement prepareCall(String sql)        throws java.sql.SQLException {        if (this.getUseUltraDevWorkAround()) {            return new UltraDevWorkAround(prepareStatement(sql));        } else {            throw new java.sql.SQLException("Callable statments not "                + "supported.", "S1C00");        }    }    /**     * JDBC 2.0 Same as prepareCall() above, but allows the default result set     * type and result set concurrency type to be overridden.     *     * @param sql the SQL representing the callable statement     * @param resultSetType a result set type, see ResultSet.TYPE_XXX     * @param resultSetConcurrency a concurrency type, see ResultSet.CONCUR_XXX     *     * @return a new CallableStatement object containing the pre-compiled SQL     *         statement     *     * @exception SQLException if a database-access error occurs.     */    public java.sql.CallableStatement prepareCall(String sql,        int resultSetType, int resultSetConcurrency) throws SQLException {        return prepareCall(sql);    }    /**     * @see Connection#prepareCall(String, int, int, int)     */    public java.sql.CallableStatement prepareCall(String sql,        int resultSetType, int resultSetConcurrency, int resultSetHoldability)        throws SQLException {        if (this.pedantic) {            if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT) {                throw new SQLException("HOLD_CUSRORS_OVER_COMMIT is only supported holdability level",                    SQLError.SQL_STATE_ILLEGAL_ARGUMENT);            }        }        throw new NotImplemented();    }    /**     * A SQL statement with or without IN parameters can be pre-compiled and     * stored in a PreparedStatement object.  This object can then be used to     * efficiently execute this statement multiple times.     *      * <p>     * <B>Note:</B> This method is optimized for handling parametric SQL     * statements that benefit from precompilation if the driver supports     * precompilation. In this case, the statement is not sent to the database     * until the PreparedStatement is executed.  This has no direct effect on     * users; however it does affect which method throws certain     * java.sql.SQLExceptions     * </p>     *      * <p>     * MySQL does not support precompilation of statements, so they are handled     * by the driver.     * </p>     *     * @param sql a SQL statement that may contain one or more '?' IN parameter     *        placeholders     *     * @return a new PreparedStatement object containing the pre-compiled     *         statement.     *     * @exception java.sql.SQLException if a database access error occurs.     */    public java.sql.PreparedStatement prepareStatement(String sql)        throws java.sql.SQLException {        return prepareStatement(sql, java.sql.ResultSet.TYPE_FORWARD_ONLY,            java.sql.ResultSet.CONCUR_READ_ONLY);    }    /**     * JDBC 2.0 Same as prepareStatement() above, but allows the default result     * set type and result set concurrency type to be overridden.     *     * @param sql the SQL query containing place holders     * @param resultSetType a result set type, see ResultSet.TYPE_XXX     * @param resultSetConcurrency a concurrency type, see ResultSet.CONCUR_XXX     *     * @return a new PreparedStatement object containing the pre-compiled SQL     *         statement     *     * @exception SQLException if a database-access error occurs.     */    public synchronized java.sql.PreparedStatement prepareStatement(        String sql, int resultSetType, int resultSetConcurrency)        throws SQLException {        checkClosed();        PreparedStatement pStmt = null;        if (this.cachePreparedStatements) {            PreparedStatement.ParseInfo pStmtInfo = (PreparedStatement.ParseInfo) cachedPreparedStatementParams                .get(sql);            if (pStmtInfo == null) {                pStmt = new com.mysql.jdbc.PreparedStatement(this, sql,                        this.database);                PreparedStatement.ParseInfo parseInfo = pStmt.getParseInfo();                if (parseInfo.statementLength < this.preparedStatementCacheMaxSqlSize) {                    if (this.cachedPreparedStatementParams.size() >= 25) {                        Iterator oldestIter = this.cachedPreparedStatementParams.keySet()                                                                                .iterator();                        long lruTime = Long.MAX_VALUE;                        String oldestSql = null;                        while (oldestIter.hasNext()) {                            String sqlKey = (String) oldestIter.next();                            PreparedStatement.ParseInfo lruInfo = (PreparedStatement.ParseInfo) this.cachedPreparedStatementParams                                .get(sqlKey);                            if (lruInfo.lastUsed < lruTime) {                                lruTime = lruInfo.lastUsed;                                oldestSql = sqlKey;                            }                        }                        if (oldestSql != null) {                            this.cachedPreparedStatementParams.remove(oldestSql);                        }                    }                    cachedPreparedStatementParams.put(sql, pStmt.getParseInfo());                }            } else {                pStmtInfo.lastUsed = System.currentTimeMillis();                pStmt = new com.mysql.jdbc.PreparedStatement(this, sql,                        this.database, pStmtInfo);            }        } else {            pStmt = new com.mysql.jdbc.PreparedStatement(this, sql,                    this.database);        }        //        // FIXME: Create warnings if can't create results of the given        //        type or concurrency        //        pStmt.setResultSetType(resultSetType);        pStmt.setResultSetConcurrency(resultSetConcurrency);        return pStmt;    }    /**     * @see Connection#prepareStatement(String, int, int, int)     */    public java.sql.PreparedStatement prepareStatement(String sql,        int resultSetType, int resultSetConcurrency, int resultSetHoldability)        throws SQLException {        if (this.pedantic) {            if (resultSetHoldability != ResultSet.HOLD_CURSORS_OVER_COMMIT) {                throw new SQLException("HOLD_CUSRORS_OVER_COMMIT is only supported holdability level",                    SQLError.SQL_STATE_ILLEGAL_ARGUMENT);            }        }        return prepareStatement(sql, resultSetType, resultSetConcurrency);    }    /**     * @see Connection#prepareStatement(String, int)     */    public java.sql.PreparedStatement prepareStatement(String sql,        int autoGenKeyIndex) throws SQLException {        java.sql.PreparedStatement pStmt = prepareStatement(sql);        ((com.mysql.jdbc.PreparedStatement) pStmt).setRetrieveGeneratedKeys(autoGenKeyIndex == Statement.RETURN_GENERATED_KEYS);        return pStmt;    }    /**     * @see Connection#prepareStatement(String, int[])     */    public java.sql.PreparedStatement prepareStatement(String sql,        int[] autoGenKeyIndexes) throws SQLException {        java.sql.PreparedStatement pStmt = prepareStatement(sql);        ((com.mysql.jdbc.PreparedStatement) pStmt).setRetrieveGeneratedKeys((autoGenKeyIndexes != null)            && (autoGenKeyIndexes.length > 0));        return pStmt;    }    /**     * @see Connection#prepareStatement(String, String[])     */    public java.sql.PreparedStatement prepareStatement(String sql,        String[] autoGenKeyColNames) throws SQLException {        java.sql.PreparedStatement pStmt = prepareStatement(sql);        ((com.mysql.jdbc.PreparedStatement) pStmt).setRetrieveGeneratedKeys((autoGenKeyColNames != null)            && (autoGenKeyColNames.length > 0));        return pStmt;    }    /**     * @see Connection#releaseSavepoint(Savepoint)     */    public void releaseSavepoint(Savepoint arg0) throws SQLException {        throw new NotImplemented();    }    /**     * Resets the server-side state of this connection. Doesn't work for MySQL     * versions older than 4.0.6 or if isParanoid() is set (it will become  a     * no-op in these cases). Usually only used from connection pooling code.     *     * @throws SQLException if the operation fails while resetting server     *         state.     */    public void resetServerState() throws SQLException {    	        if (!this.paranoid                && ((this.io != null) & this.io.versionMeetsMinimum(4, 0, 6))) {            changeUser(this.user, this.password);        }    }    /**     * The method rollback() drops all changes made since the previous     * commit/rollback and releases any database locks currently held by the     * Connection.     *     * @exception java.sql.SQLException if a database access error occurs     * @throws SQLException DOCUMENT ME!     *     * @see commit     */    public void rollback() throws java.sql.SQLException {        if (Driver.TRACE) {            Object[] args = new Object[0];            Debug.methodCall(this, "rollback", args);        }        checkClosed();        try {            // no-op if _relaxAutoCommit == true            if (this.autoCommit && !this.relaxAutoCommit) {                throw new SQLException("Can't call rollback when autocommit=true",                    SQLError.SQL_STATE_GENERAL_ERROR);            } else if (this.transactionsSupported) {                try {                    rollbackNoChecks();                } catch (SQLException sqlEx) {                    // We ignore non-transactional tables if told to do so                    if (this.ignoreNonTxTables                            && (sqlEx.getErrorCode() != MysqlDefs.ER_WARNING_NOT_COMPLETE_ROLLBACK)) {                        throw sqlEx;                    }                }            }        } finally {            if (this.reconnectAtTxEnd) {                pingAndReconnect(true);            }        }    }    /**     * @see Connection#rollback(Savepoint)     */    public void rollback(Savepoint arg0) throws SQLException {        throw new NotImplemented();    }    /**     * Used by MiniAdmin to shutdown a MySQL server     *     * @throws SQLException if the command can not be issued.     */    public void shutdownServer() throws SQLException {        try {            this.io.sendCommand(MysqlDefs.SHUTDOWN, null, null);        } catch (Exception ex) {            throw new SQLException("Unhandled exception '" + ex.toString()                + "'", SQLError.SQL_STATE_GENERAL_ERROR);        }    }    /**     * DOCUMENT ME!     *     * @return DOCUMENT ME!     */    public boolean supportsIsolationLevel() {        return this.hasIsolationLevels;    }

⌨️ 快捷键说明

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