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

📄 callablestatement.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/*   Derby - Class org.apache.derby.client.am.CallableStatement   Copyright (c) 2001, 2005 The Apache Software Foundation or its licensors, where applicable.   Licensed under the Apache License, Version 2.0 (the "License");   you may not use this file except in compliance with the License.   You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0   Unless required by applicable law or agreed to in writing, software   distributed under the License is distributed on an "AS IS" BASIS,   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   See the License for the specific language governing permissions and   limitations under the License.*/package org.apache.derby.client.am;public class CallableStatement extends PreparedStatement        implements java.sql.PreparedStatement,        java.sql.CallableStatement,        PreparedStatementCallbackInterface {    //---------------------navigational members-----------------------------------    //---------------------navigational cheat-links-------------------------------    // Cheat-links are for convenience only, and are not part of the conceptual model.    // Warning:    //   Cheat-links should only be defined for invariant state data.    //   That is, the state data is set by the constructor and never changes.    public MaterialPreparedStatement materialCallableStatement_ = null;    //-----------------------------state------------------------------------------    // last retrieved result was a sql NULL, NOT_NULL, or UNSET.    private int wasNull_ = WAS_NULL_UNSET;    static final private int WAS_NULL = 1;    static final private int WAS_NOT_NULL = 2;    static final private int WAS_NULL_UNSET = 0;    //---------------------constructors/finalizer---------------------------------    private void initCallableStatement() {        materialCallableStatement_ = null;        wasNull_ = WAS_NULL_UNSET;    }    public void reset(boolean fullReset) throws SqlException {        if (fullReset) {            connection_.resetPrepareCall(this);        } else {            super.reset(fullReset);        }        wasNull_ = WAS_NULL_UNSET;    }    // Common constructor for jdbc 2 callable statements with scroll attributes.    // Called by material statement constructor.    public CallableStatement(Agent agent,                             Connection connection,                             String sql,                             int type, int concurrency, int holdability) throws SqlException {        super(agent, connection, sql, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, null);        initCallableStatement();    }    public void resetCallableStatement(Agent agent,                                       Connection connection,                                       String sql,                                       int type, int concurrency, int holdability) throws SqlException {        super.resetPreparedStatement(agent, connection, sql, type, concurrency, holdability, java.sql.Statement.NO_GENERATED_KEYS, null);        initCallableStatement();    }    public void resetCallableStatement(Agent agent,                                       Connection connection,                                       String sql,                                       Section section) throws SqlException {        super.resetPreparedStatement(agent, connection, sql, section);        initCallableStatement();    }    public void resetCallableStatement(Agent agent,                                       Connection connection,                                       String sql,                                       Section section,                                       ColumnMetaData parameterMetaData,                                       ColumnMetaData resultSetMetaData) throws SqlException {        super.resetPreparedStatement(agent, connection, sql, section, parameterMetaData, resultSetMetaData);        initCallableStatement();    }    protected void finalize() throws java.lang.Throwable {        if (agent_.loggingEnabled()) {            agent_.logWriter_.traceEntry(this, "finalize");        }        super.finalize();    }    //---------------------------entry points-------------------------------------    public boolean execute() throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "execute");            }            boolean b = executeX();            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceExit(this, "execute", b);            }            return b;        }    }    // also used by SQLCA    boolean executeX() throws SqlException {        super.flowExecute(executeMethod__);        return resultSet_ != null;    }    public java.sql.ResultSet executeQuery() throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "executeQuery");            }            ResultSet resultSet = executeQueryX();            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceExit(this, "executeQuery", resultSet);            }            return resultSet;        }    }    // also used by DBMD methods    ResultSet executeQueryX() throws SqlException {        super.flowExecute(executeQueryMethod__);        super.checkExecuteQueryPostConditions("java.sql.CallableStatement");        return resultSet_;    }    public int executeUpdate() throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "executeUpdate");            }            int updateValue = executeUpdateX();            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceExit(this, "executeUpdate", updateValue);            }            return updateValue;        }    }    int executeUpdateX() throws SqlException {        super.flowExecute(executeUpdateMethod__);        super.checkExecuteUpdatePostConditions("java.sql.CallableStatement");        // make sure update count >= 0 even if derby don't support update count for call        //return (updateCount_ < 0) ? 0 : updateCount_;        return updateCount_;    }    public void clearParameters() throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "clearParameters");            }            super.clearParameters();            outputRegistered_ = false; // this variable is only used by Batch        }    }    public void registerOutParameter(int parameterIndex, int jdbcType) throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "registerOutParameter", parameterIndex, jdbcType);            }            registerOutParameterX(parameterIndex, jdbcType);        }    }    // also used by Sqlca    void registerOutParameterX(int parameterIndex, int jdbcType) throws SqlException {        super.checkForClosedStatement();        int scale = 0; // default scale to 0 for non numeric and non decimal type        registerOutParameterX(parameterIndex, jdbcType, scale);    }    private int guessScaleForDecimalOrNumeric(int parameterIndex) throws SqlException {        parameterIndex = checkForEscapedCallWithResult(parameterIndex);        // Types.DECIMAL with no supplied scale will use the scale supplied by the setter method if input BigDecimal is not null        if (parameterMetaData_.types_[parameterIndex - 1] == Types.DECIMAL &&                parameters_[parameterIndex - 1] != null) {            return parameterMetaData_.sqlScale_[parameterIndex - 1];        }        return 8; // default to scale of 8 if not specified    }    public void registerOutParameter(int parameterIndex, int jdbcType, int scale) throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "registerOutParameter", parameterIndex, jdbcType, scale);            }            super.checkForClosedStatement();            registerOutParameterX(parameterIndex, jdbcType, scale);        }    }    private void registerOutParameterX(int parameterIndex, int jdbcType, int scale) throws SqlException {        parameterIndex = checkForEscapedCallWithResult(parameterIndex, jdbcType);        // if the parameter is the return clause of the call statement        if (parameterIndex == 0 && escapedProcedureCallWithResult_) {            return;        }        super.checkForValidParameterIndex(parameterIndex);        checkForValidScale(scale);        outputRegistered_ = true; // this variable is only used by Batch        //parameterSetOrRegistered_[parameterIndex - 1] = true;        parameterRegistered_[parameterIndex - 1] = true;    }    public void registerOutParameter(int parameterIndex, int jdbcType, String typeName) throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "registerOutParameter", parameterIndex, jdbcType, typeName);            }            super.checkForClosedStatement();        }    }    public boolean wasNull() throws SqlException {        if (agent_.loggingEnabled()) {            agent_.logWriter_.traceEntry(this, "wasNull");        }        boolean result = wasNullX();        if (agent_.loggingEnabled()) {            agent_.logWriter_.traceExit(this, "wasNull", result);        }        return result;    }    private boolean wasNullX() throws SqlException {        super.checkForClosedStatement();        if (wasNull_ == WAS_NULL_UNSET) {            throw new SqlException(agent_.logWriter_, "Invalid operation: wasNull() called with no data retrieved.");        }        return wasNull_ == WAS_NULL;    }    //--------------------------------getter methods------------------------------    public boolean getBoolean(int parameterIndex) throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "getBoolean", parameterIndex);            }            super.checkForClosedStatement();            parameterIndex = checkForEscapedCallWithResult(parameterIndex);            boolean result;            if (parameterIndex == 0 && escapedProcedureCallWithResult_) {                result = agent_.crossConverters_.getBooleanFromInt(returnValueFromProcedure_);                this.wasNull_ = this.WAS_NOT_NULL;                if (agent_.loggingEnabled()) {                    agent_.logWriter_.traceExit(this, "getBoolean", result);                }                return result;            }            checkGetterPreconditions(parameterIndex);            setWasNull(parameterIndex);            result = wasNullX() ? false : singletonRowData_.getBoolean(parameterIndex);            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceExit(this, "getBoolean", result);            }            return result;        }    }    public byte getByte(int parameterIndex) throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "getByte", parameterIndex);            }            super.checkForClosedStatement();            parameterIndex = checkForEscapedCallWithResult(parameterIndex);            byte result;            if (parameterIndex == 0 && escapedProcedureCallWithResult_) {                result = agent_.crossConverters_.getByteFromInt(returnValueFromProcedure_);                this.wasNull_ = this.WAS_NOT_NULL;                if (agent_.loggingEnabled()) {                    agent_.logWriter_.traceExit(this, "getByte", result);                }                return result;            }            checkGetterPreconditions(parameterIndex);            setWasNull(parameterIndex);            result = wasNullX() ? 0 : singletonRowData_.getByte(parameterIndex);            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceExit(this, "getByte", result);            }            return result;        }    }    public short getShort(int parameterIndex) throws SqlException {        synchronized (connection_) {            if (agent_.loggingEnabled()) {                agent_.logWriter_.traceEntry(this, "getShort", parameterIndex);            }            super.checkForClosedStatement();            parameterIndex = checkForEscapedCallWithResult(parameterIndex);            short result;            if (parameterIndex == 0 && escapedProcedureCallWithResult_) {

⌨️ 快捷键说明

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