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

📄 statement.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        }        switch (concurrency) {        case java.sql.ResultSet.CONCUR_READ_ONLY:        case java.sql.ResultSet.CONCUR_UPDATABLE:            resultSetConcurrency_ = concurrency;            break;        default:            throw new SqlException(agent_.logWriter_, "Invalid argument: " +                    "ResultSet Concurrency " + concurrency + " is invalid.");        }        switch (holdability) {        case org.apache.derby.jdbc.ClientDataSource.CLOSE_CURSORS_AT_COMMIT:        case org.apache.derby.jdbc.ClientDataSource.HOLD_CURSORS_OVER_COMMIT:            resultSetHoldability_ = holdability;            break;        default:            throw new SqlException(agent_.logWriter_, "Invalid argument: " +                    "ResultSet holdability " + holdability + " is invalid.");        }        switch (autoGeneratedKeys) {        case java.sql.Statement.NO_GENERATED_KEYS:        case java.sql.Statement.RETURN_GENERATED_KEYS:            autoGeneratedKeys_ = autoGeneratedKeys;            break;        default:            throw new SqlException(agent_.logWriter_, "Invalid argument: " +                    "Statement auto-generated keys value " + autoGeneratedKeys +                    " is invalid.");        }        generatedKeysColumnNames_ = columnNames;    }    /* (non-Javadoc)     * @see java.lang.Object#finalize()     *      * This method cleans up client-side resources by calling markClosed().     * It is different from close() method, which also does clean up on server.     * Changes done as part of DERBY-210.      */    protected void finalize() throws java.lang.Throwable {        if (agent_.loggingEnabled()) {            agent_.logWriter_.traceEntry(this, "finalize");        }        if (openOnClient_) {            markClosed();        }        super.finalize();    }    // ---------------------------jdbc 1------------------------------------------    public java.sql.ResultSet executeQuery(String sql) throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "executeQuery", sql);            }            ResultSet resultSet = executeQueryX(sql);            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceExit(this, "executeQuery", resultSet);            }            return resultSet;        }    }    private ResultSet executeQueryX(String sql) throws SqlException {        flowExecute(executeQueryMethod__, sql);        checkExecuteQueryPostConditions("java.sql.Statement");        return resultSet_;    }    void checkExecuteQueryPostConditions(String jdbcStatementInterfaceName) throws SqlException {        // We'll just rely on finalizers to close the dangling result sets.        if (resultSetList_ != null && resultSetList_.length != 1) {            throw new SqlException(agent_.logWriter_, jdbcStatementInterfaceName + ".executeQuery() cannot be called " +                    "because multiple result sets were returned." +                    " Use " + jdbcStatementInterfaceName + ".execute() to obtain multiple results.");        }        if (resultSet_ == null) {            throw new SqlException(agent_.logWriter_, jdbcStatementInterfaceName + ".executeQuery() was called " +                    "but no result set was returned." +                    " Use " + jdbcStatementInterfaceName + ".executeUpdate() for non-queries.");        }    }    public int executeUpdate(String sql) throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "executeUpdate", sql);            }            int updateValue = executeUpdateX(sql);            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceExit(this, "executeUpdate", updateValue);            }            return updateValue;        }    }    private int executeUpdateX(String sql) throws SqlException {        flowExecute(executeUpdateMethod__, sql);        checkExecuteUpdatePostConditions("java.sql.Statement");        return updateCount_;    }    void checkExecuteUpdatePostConditions(String jdbcStatementInterfaceName) throws SqlException {        // We'll just rely on finalizers to close the dangling result sets.        if (resultSetList_ != null) {            throw new SqlException(agent_.logWriter_, jdbcStatementInterfaceName + ".executeUpdate() cannot be called " +                    "because multiple result sets returned." +                    " Use " + jdbcStatementInterfaceName + ".execute() to obtain multiple results.");        }        // We'll just rely on the finalizer to close the dangling result set.        if (resultSet_ != null) {            throw new SqlException(agent_.logWriter_, jdbcStatementInterfaceName + ".executeUpdate() was called " +                    "but a result set was returned." +                    " Use " + jdbcStatementInterfaceName + ".executeQuery() to obtain a result set.");        }    }    // The server holds statement resources until transaction end.    public void close() throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "close");            }            closeX();        }    }    /**     * An untraced version of <code>close</code>. This method cleans up      * client-side resources and also sends commands to network server to      * perform clean up. This should not be called in the finalizer.      * Difference between <code>finalize</code> and <code>close</code> is     * that close method does these things additionally (Changes done as      * part of DERBY-210):     * 1) Sends commands to the server to close the result sets.     * 2) Sends commands to the server to close the result sets of the      * generated keys query.     * 3) Sends a commit if autocommit is on and it is appropriate.     * 4) Explicitly removes the statement from connection_.openStatements_      * and CommitAndRollbackListeners_ by passing true to markClosed.       *      * We may need to do 1) in finalizer too. This is being tracked in      * DERBY-1021     *      * @throws SqlException     */    public void closeX() throws SqlException {        if (!openOnClient_) {            return;        }        // Regardless of whether or not this statement is in the prepared state,        // we need to close any open cursors for this statement on the server.        int numberOfResultSetsToClose = (resultSetList_ == null) ? 0 : resultSetList_.length;        boolean willTickleServer = willTickleServer(numberOfResultSetsToClose, true);        try {            if (willTickleServer) {                flowClose();            } else {                flowCloseOutsideUOW();            }        } finally {            markClosed(true);        }    }    public int getMaxFieldSize() throws SqlException {        if (agent_.loggingEnabled()) {            agent_.logWriter_.traceEntry(this, "getMaxFieldSize");        }        checkForClosedStatement();        return maxFieldSize_;    }    public void setMaxFieldSize(int max) throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "setMaxFieldSize", max);            }            checkForClosedStatement();            if (max < 0) {                throw new SqlException(agent_.logWriter_, "Invalid maxFieldSize value: " + max);            }            maxFieldSize_ = max;        }    }    public int getMaxRows() throws SqlException {        checkForClosedStatement();        if (agent_.loggingEnabled()) {            agent_.logWriter_.traceExit(this, "getMaxRows", maxRows_);        }        return maxRows_;    }    public void setMaxRows(int maxRows) throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "setMaxRows", maxRows);            }            checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc)            if (maxRows < 0) {                throw new SqlException(agent_.logWriter_, "Invalid maxRows value: " + maxRows);            }            maxRows_ = maxRows;        }    }    public void setEscapeProcessing(boolean enable) throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "setEscapeProcessing", enable);            }            checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc)        }    }    public int getQueryTimeout() throws SqlException {        checkForClosedStatement();        if (agent_.loggingEnabled()) {            agent_.logWriter_.traceExit(this, "getQueryTimeout", timeout_);        }        return timeout_;    }    public void setQueryTimeout(int seconds) throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "setQueryTimeout", seconds);            }            checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc)            if (seconds < 0) {                throw new SqlException(agent_.logWriter_, "Attempt to set a negative query timeout");            }            timeout_ = seconds; // java.util.Timer takes milliseconds        }    }    public void cancel() throws SqlException {        if (agent_.loggingEnabled()) {            agent_.logWriter_.traceEntry(this, "cancel");        }        checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc)        throw new SqlException(agent_.logWriter_, "cancel() not supported by server");    }    public java.sql.SQLWarning getWarnings() throws SqlException {        if (agent_.loggingEnabled()) {            agent_.logWriter_.traceExit(this, "getWarnings", warnings_);        }        return warnings_;    }    public void clearWarnings() throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "clearWarnings");            }            clearWarningsX();        }    }    // An untraced version of clearWarnings()    public void clearWarningsX() {        warnings_ = null;    }    // Dnc statements are already associated with a unique cursor name as defined    // by our canned dnc package set.    // ResultSet.getCursorName() should be used to    // obtain the for update cursor name to use when executing a positioned update statement.    // See Jdbc 3 spec section 14.2.4.4.    public void setCursorName(String name) throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "setCursorName", name);            }            checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc)            if (name == null || name.equals("")) {                throw new SqlException(agent_.logWriter_, "Invalid cursor name.");            }            // Invalid to set the cursor name if there are ResultSet's open on the Statement.            if (resultSet_ != null && resultSet_.openOnClient_) {                throw new SqlException(agent_.logWriter_, "Invalid operation: setCursorName() " +                        "called when there are open ResultSet's on the Statement.");            }            // Duplicate cursor names not allowed.            if (connection_.clientCursorNameCache_.containsKey(name)) {                throw new SqlException(agent_.logWriter_, "Duplicate cursor names are not allowed.");            }            connection_.clientCursorNameCache_.put(name, name);            // section_ is null for Statement objects.  We will defer the mapping of cursorName            // to section until when the query is executed.            if (section_ != null) {                agent_.sectionManager_.mapCursorNameToQuerySection(name, (Section) section_);                // This means we must subtitute the <users-cursor-name> with the <canned-cursor-name>                // in the pass-thru sql string "...where current of <canned-cursor-name>".                section_.setClientCursorName(name);            }            cursorName_ = name;        }    }

⌨️ 快捷键说明

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