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

📄 netstatementreply.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/*   Derby - Class org.apache.derby.client.net.NetStatementReply   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.net;import org.apache.derby.client.am.ColumnMetaData;import org.apache.derby.client.am.DisconnectException;import org.apache.derby.client.am.PreparedStatementCallbackInterface;import org.apache.derby.client.am.ResultSetCallbackInterface;import org.apache.derby.client.am.Section;import org.apache.derby.client.am.SqlState;import org.apache.derby.client.am.Statement;import org.apache.derby.client.am.StatementCallbackInterface;import org.apache.derby.client.am.Types;import org.apache.derby.client.am.Utils;public class NetStatementReply extends NetPackageReply implements StatementReplyInterface {    NetStatementReply(NetAgent netAgent, int bufferSize) {        super(netAgent, bufferSize);    }    //----------------------------- entry points ---------------------------------    public void readPrepareDescribeOutput(StatementCallbackInterface statement) throws DisconnectException {        startSameIdChainParse();        parsePRPSQLSTTreply(statement);        endOfSameIdChainData();    }    public void readExecuteImmediate(StatementCallbackInterface statement) throws DisconnectException {        startSameIdChainParse();        parseEXCSQLIMMreply(statement);        endOfSameIdChainData();    }    public void readOpenQuery(StatementCallbackInterface statement) throws DisconnectException {        startSameIdChainParse();        parseOPNQRYreply(statement);        endOfSameIdChainData();    }    public void readExecute(PreparedStatementCallbackInterface preparedStatement) throws DisconnectException {        startSameIdChainParse();        parseEXCSQLSTTreply(preparedStatement);        endOfSameIdChainData();    }    public void readPrepare(StatementCallbackInterface statement) throws DisconnectException {        startSameIdChainParse();        parsePRPSQLSTTreply(statement);        endOfSameIdChainData();    }    public void readDescribeInput(PreparedStatementCallbackInterface preparedStatement) throws DisconnectException {        if (longBufferForDecryption_ != null) {            buffer_ = longBufferForDecryption_;            pos_ = longPosForDecryption_;            count_ = longCountForDecryption_;            if (longBufferForDecryption_ != null && count_ > longBufferForDecryption_.length) {                count_ = longBufferForDecryption_.length;            }            dssLength_ = 0;            longBufferForDecryption_ = null;        }        startSameIdChainParse();        parseDSCSQLSTTreply(preparedStatement, 1); // anything other than 0 for input        endOfSameIdChainData();    }    public void readDescribeOutput(PreparedStatementCallbackInterface preparedStatement) throws DisconnectException {        startSameIdChainParse();        parseDSCSQLSTTreply(preparedStatement, 0);  // 0 for output        endOfSameIdChainData();    }    public void readExecuteCall(StatementCallbackInterface statement) throws DisconnectException {        startSameIdChainParse();        parseEXCSQLSTTreply(statement);        endOfSameIdChainData();    }    //----------------------helper methods----------------------------------------    //------------------parse reply for specific command--------------------------    // These methods are "private protected", which is not a recognized java privilege,    // but means that these methods are private to this class and to subclasses,    // and should not be used as package-wide friendly methods.    private void parsePRPSQLSTTreply(StatementCallbackInterface statement) throws DisconnectException {        int peekCP = parseTypdefsOrMgrlvlovrs();        if (peekCP == CodePoint.SQLDARD) {            // the sqlcagrp is most likely null for insert/update/deletes.  if it is null, then we can            // peek ahead for the column number which most likely will be 0.  if it is 0, then we will            // not new up a ColumnMetaData, and we can skip the rest of the bytes in sqldard.            // if sqlcargrp is not null, (most likely for select's) then we will not peek ahead for the            // column number since it will never be 0 in a select case.            ColumnMetaData columnMetaData = null;            NetSqlca netSqlca = null;            boolean nullSqlca = peekForNullSqlcagrp();            if (nullSqlca && peekNumOfColumns() == 0) {                netSqlca = parseSQLDARD(columnMetaData, true); // true means to skip the rest of SQLDARD bytes            } else {                columnMetaData = new ColumnMetaData(netAgent_.logWriter_);                netSqlca = parseSQLDARD(columnMetaData, false); // false means do not skip SQLDARD bytes.            }            statement.completePrepareDescribeOutput(columnMetaData,                    netSqlca);        } else if (peekCP == CodePoint.SQLCARD) {            NetSqlca netSqlca = parseSQLCARD(null);            statement.completePrepare(netSqlca);        } else {            parsePrepareError(statement);        }    }    // Parse the reply for the Describe SQL Statement Command.    // This method handles the parsing of all command replies and reply data    // for the dscsqlstt command.    private void parseDSCSQLSTTreply(PreparedStatementCallbackInterface ps,                                     int metaDataType) // 0 is output, else input            throws DisconnectException {        int peekCP = parseTypdefsOrMgrlvlovrs();        if (peekCP == CodePoint.SQLDARD) {            ColumnMetaData columnMetaData = null;            if (columnMetaData == null) {                columnMetaData = new ColumnMetaData(netAgent_.logWriter_);            }            NetSqlca netSqlca = parseSQLDARD(columnMetaData, false);  // false means do not skip SQLDARD bytes            if (columnMetaData.columns_ == 0) {                columnMetaData = null;            }            if (metaDataType == 0) // DESCRIBE OUTPUT            {                ps.completeDescribeOutput(columnMetaData, netSqlca);            } else {                ps.completeDescribeInput(columnMetaData, netSqlca);            }        } else if (peekCP == CodePoint.SQLCARD) {            NetSqlca netSqlca = parseSQLCARD(null);            if (metaDataType == 0) // DESCRIBE OUTPUT            {                ps.completeDescribeOutput(null, netSqlca);            } else {                ps.completeDescribeInput(null, netSqlca);            }        } else {            parseDescribeError(ps);        }    }    // Parse the reply for the Execute Immediate SQL Statement Command.    // This method handles the parsing of all command replies and reply data    // for the excsqlimm command.    private void parseEXCSQLIMMreply(StatementCallbackInterface statement) throws DisconnectException {        int peekCP = parseTypdefsOrMgrlvlovrs();        if (peekCP == CodePoint.RDBUPDRM) {            parseRDBUPDRM();            peekCP = parseTypdefsOrMgrlvlovrs();        }        switch (peekCP) {        case CodePoint.ENDUOWRM:            parseENDUOWRM(statement.getConnectionCallbackInterface());            parseTypdefsOrMgrlvlovrs();        case CodePoint.SQLCARD:            NetSqlca netSqlca = parseSQLCARD(null);            statement.completeExecuteImmediate(netSqlca);            break;        default:            parseExecuteImmediateError(statement);            break;        }    }    // Parse the reply for the Open Query Command.    // This method handles the parsing of all command replies and reply data for the opnqry command.    // will be replaced by parseOPNQRYreply (see parseOPNQRYreplyProto)    private void parseOPNQRYreply(StatementCallbackInterface statementI) throws DisconnectException {        int peekCP = peekCodePoint();        if (peekCP == CodePoint.OPNQRYRM) {            parseOpenQuery(statementI);            peekCP = peekCodePoint();            if (peekCP == CodePoint.RDBUPDRM) {                parseRDBUPDRM();                peekCP = peekCodePoint();            }        } else if (peekCP == CodePoint.RDBUPDRM) {            parseRDBUPDRM();            parseOpenQuery(statementI);            peekCP = peekCodePoint();        } else if (peekCP == CodePoint.OPNQFLRM) {            parseOpenQueryFailure(statementI);            peekCP = peekCodePoint();        } else {            parseOpenQueryError(statementI);            peekCP = peekCodePoint();        }    }    // Called by NETSetClientPiggybackCommand.read()    private void parseEXCSQLSETreply(StatementCallbackInterface statement) throws DisconnectException {        int peekCP = parseTypdefsOrMgrlvlovrs();        if (peekCP == CodePoint.RDBUPDRM) {            parseRDBUPDRM();            parseTypdefsOrMgrlvlovrs();        } else if (peekCP == CodePoint.ENDUOWRM) {            parseENDUOWRM(statement.getConnectionCallbackInterface());            parseTypdefsOrMgrlvlovrs();        }        if (peekCP == CodePoint.SQLCARD) {            NetSqlca netSqlca = parseSQLCARD(null);            statement.completeExecuteSetStatement(netSqlca);        } else {            parseExecuteSetStatementError(statement);        }    }    // Parse the reply for the Execute SQL Statement Command.    // This method handles the parsing of all command replies and reply data    // for the excsqlstt command.    // Also called by CallableStatement.readExecuteCall()    private void parseEXCSQLSTTreply(StatementCallbackInterface statementI) throws DisconnectException {        // first handle the transaction component, which consists of one or more        // reply messages indicating the transaction state.        // These are ENDUOWRM, CMMRQSRM, or RDBUPDRM.  If RDBUPDRM is returned,        // it may be followed by ENDUOWRM or CMMRQSRM        int peekCP = peekCodePoint();        if (peekCP == CodePoint.RDBUPDRM) {            parseRDBUPDRM();            peekCP = peekCodePoint();        }        if (peekCP == CodePoint.ENDUOWRM) {            parseENDUOWRM(statementI.getConnectionCallbackInterface());            peekCP = peekCodePoint();        }        // Check for a RSLSETRM, this is first rm of the result set summary component        // which would be returned if a stored procedure was called which returned result sets.        if (peekCP == CodePoint.RSLSETRM) {            parseResultSetProcedure(statementI);            peekCP = peekCodePoint();            if (peekCP == CodePoint.RDBUPDRM) {                parseRDBUPDRM();            }            return;        }        // check for a possible TYPDEFNAM or TYPDEFOVR which may be present        // before the SQLCARD or SQLDTARD.        peekCP = parseTypdefsOrMgrlvlovrs();        // an SQLCARD may be retunred if there was no output data, result sets or parameters,        // or in the case of an error.        if (peekCP == CodePoint.SQLCARD) {            NetSqlca netSqlca = parseSQLCARD(null);            statementI.completeExecute(netSqlca);        } else if (peekCP == CodePoint.SQLDTARD) {            // in the case of singleton select or if a stored procedure was called which had            // parameters but no result sets, an SQLSTARD may be returned            // keep the PreparedStatementCallbackInterface, since only preparedstatement and callablestatement            // has parameters or singleton select which translates to sqldtard.            NetSqldta netSqldta = null;            boolean useCachedSingletonRowData = false;            if (((Statement) statementI).cachedSingletonRowData_ == null) {                netSqldta = new NetSqldta(netAgent_);            } else {                netSqldta = (NetSqldta) ((Statement) statementI).cachedSingletonRowData_;                netSqldta.resetDataBuffer();                netSqldta.extdtaData_.clear();                useCachedSingletonRowData = true;            }            NetSqlca netSqlca =                    parseSQLDTARD(netSqldta);            // there may be externalized LOB data which also gets returned.            peekCP = peekCodePoint();            while (peekCP == CodePoint.EXTDTA) {

⌨️ 快捷键说明

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