You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by jb...@apache.org on 2005/05/02 08:26:03 UTC
svn commit: r165585 [33/42] - in
/incubator/derby/code/trunk/java/client/org/apache/derby: client/
client/am/ client/net/ client/resources/ jdbc/
Modified: incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java
URL: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java?rev=165585&r1=165584&r2=165585&view=diff
==============================================================================
--- incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java (original)
+++ incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatementReply.java Sun May 1 23:25:59 2005
@@ -20,2370 +20,2335 @@
package org.apache.derby.client.net;
-import org.apache.derby.client.am.Agent;
-import org.apache.derby.client.am.SqlState;
-import org.apache.derby.client.am.Statement;
import org.apache.derby.client.am.ColumnMetaData;
import org.apache.derby.client.am.DisconnectException;
-import org.apache.derby.client.am.Utils;
-import org.apache.derby.client.am.Types;
-import org.apache.derby.client.am.Section;
-import org.apache.derby.client.am.StatementCallbackInterface;
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();
- }
+public class NetStatementReply extends NetPackageReply implements StatementReplyInterface {
+ NetStatementReply(NetAgent netAgent, int bufferSize) {
+ super(netAgent, bufferSize);
}
- 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) {
- copyEXTDTA (netSqldta);
- peekCP = peekCodePoint();
- }
- statementI.completeExecuteCall (netSqlca, netSqldta);
+
+ //----------------------------- 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);
+ }
+
}
- else {
- // if here, then assume an error reply message was returned.
- parseExecuteError (statementI);
- }
-
- }
-
- protected void parseResultSetProcedure (StatementCallbackInterface statementI) throws DisconnectException
- {
- // when a stored procedure is called which returns result sets,
- // the next thing to be returned after the optional transaction component
- // is the summary component.
- //
- // Parse the Result Set Summary Component which consists of a
- // Result Set Reply Message, SQLCARD or SQLDTARD, and an SQL Result Set
- // Reply data object. Also check for possible TYPDEF overrides before the
- // OBJDSSs.
- // This method returns an ArrayList of generated sections which contain the
- // package and section information for the result sets which were opened on the
- // server.
-
- // the result set summary component consists of a result set reply message.
- java.util.ArrayList sectionAL = parseRSLSETRM();
-
- // following the RSLSETRM is an SQLCARD or an SQLDTARD. check for a
- // TYPDEFNAM or TYPDEFOVR before looking for these objects.
- int peekCP = parseTypdefsOrMgrlvlovrs ();
-
- // The SQLCARD and the SQLDTARD are mutually exclusive.
- // The SQLDTARD is returned if the stored procedure had parameters.
- // (Note: the SQLDTARD contains an sqlca also. this is the sqlca for the
- // stored procedure call.
- NetSqldta netSqldta = null;
- NetSqlca netSqlca = null;
- if (peekCP == CodePoint.SQLCARD) {
- netSqlca = parseSQLCARD (null);
- }
- else {
- // keep the PreparedStatementCallbackInterface, since only preparedstatement and callablestatement
- // has parameters or singleton select which translates to sqldtard.
- netSqldta = new NetSqldta (netAgent_);
- netSqlca = parseSQLDTARD (netSqldta);
- }
-
- // check for a possible TYPDEFNAM or TYPDEFOVR
- // before the SQL Result Set Reply Data object
- peekCP = parseTypdefsOrMgrlvlovrs ();
-
- int numberOfResultSets = parseSQLRSLRD (sectionAL);
-
- // The result set summary component parsed above indicated how many result sets were opened
- // by the stored pocedure call. It contained section information for
- // each of these result sets. Loop through the section array and
- // parse the result set component for each of the retunred result sets.
- NetResultSet[] resultSets = new NetResultSet[numberOfResultSets];
- for (int i = 0; i < numberOfResultSets; i++) {
- // parse the result set component of the stored procedure reply.
- NetResultSet netResultSet = parseResultSetCursor (
- statementI, (Section) sectionAL.get (i));
- resultSets[i] = netResultSet;
- }
-
- // LOBs may have been returned for one of the stored procedure parameters so
- // check for any externalized data.
- peekCP = peekCodePoint();
- while (peekCP == CodePoint.EXTDTA) {
- copyEXTDTA (netSqldta);
- peekCP = peekCodePoint();
- }
- statementI.completeExecuteCall (netSqlca, netSqldta, resultSets);
- }
-
- // Parse the Result Set component of the reply for a stored procedure
- // call which returns result sets.
- // The Result Set component consists of an Open Query Reply Message
- // followed by an optional SQLCARD, followed by an optional
- // SQL Column Information Reply data object, followed by a Query Descriptor.
- // There may also be Query Data or an End of Query Reply Message.
- protected NetResultSet parseResultSetCursor (StatementCallbackInterface statementI,
- Section section) throws DisconnectException
- {
- // The first item returne is an OPNQRYRM.
- NetResultSet netResultSet = parseOPNQRYRM (statementI);
-
- // The next to be returned is an OBJDSS so check for any TYPDEF overrides.
- int peekCP = parseTypdefsOrMgrlvlovrs ();
-
- // An SQLCARD may be returned if there were any warnings on the OPEN.
- NetSqlca netSqlca = null;
- if (peekCP == CodePoint.SQLCARD) {
- netSqlca = parseSQLCARD (null);
- peekCP = parseTypdefsOrMgrlvlovrs ();
- }
-
- // the SQLCINRD contains SQLDA like information for the result set.
- ColumnMetaData resultSetMetaData = null;
- if (peekCP == CodePoint.SQLCINRD) {
- resultSetMetaData = parseSQLCINRD();
- peekCP = parseTypdefsOrMgrlvlovrs ();
- }
-
- // A Query Descriptor must be present.
- // We cannot cache the cursor if result set is returned from a stored procedure, so
- // there is no cached cursor to use here.
- parseQRYDSC (netResultSet.netCursor_);
- peekCP = peekCodePoint();
- statementI.completeExecuteCallOpenQuery (netSqlca, netResultSet, resultSetMetaData, section);
-
- // Depending on the blocking rules, QRYDTA may have been returned on the open.
- while (peekCP == CodePoint.QRYDTA) {
- parseQRYDTA (netResultSet);
- peekCP = peekCodePoint();
- }
-
- // Under some circumstances, the server may have closed the cursor.
- // This will be indicated by an ENDQRYRM.
- if (peekCP == CodePoint.ENDQRYRM)
- parseEndQuery ((ResultSetCallbackInterface) netResultSet);
-
- return netResultSet;
- }
-
- protected void parseOpenQuery (StatementCallbackInterface statementI) throws DisconnectException
- {
- NetResultSet netResultSet = parseOPNQRYRM (statementI);
-
- NetSqlca sqlca = null;
- int peekCP = peekCodePoint();
- if (peekCP != CodePoint.QRYDSC) {
-
- peekCP = parseTypdefsOrMgrlvlovrs ();
-
- if (peekCP == CodePoint.SQLDARD) {
- ColumnMetaData columnMetaData = new ColumnMetaData (netAgent_.logWriter_);
- NetSqlca netSqlca = parseSQLDARD (columnMetaData, false); // false means do not skip SQLDARD bytes
-
- //For java stored procedure, we got the resultSetMetaData from server,
- //Do we need to save the resultSetMetaData and propagate netSqlca?
- //The following statement are doing the both, but it do more than
- //we want. It also mark the completion of Prepare 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) {
+ copyEXTDTA(netSqldta);
+ peekCP = peekCodePoint();
+ }
+ statementI.completeExecuteCall(netSqlca, netSqldta);
+ } else {
+ // if here, then assume an error reply message was returned.
+ parseExecuteError(statementI);
+ }
+
+ }
+
+ protected void parseResultSetProcedure(StatementCallbackInterface statementI) throws DisconnectException {
+ // when a stored procedure is called which returns result sets,
+ // the next thing to be returned after the optional transaction component
+ // is the summary component.
//
- // this will override the same call made from parsePrepareDescribe
- // this will not work, this is not the DA for the stored proc params
- statementI.completePrepareDescribeOutput (columnMetaData, netSqlca);
- peekCP = parseTypdefsOrMgrlvlovrs ();
- }
- // check if the DARD is mutually exclusive with CARD, if so, then the following if should be an elese
-
- if (peekCP == CodePoint.SQLCARD) {
- sqlca = parseSQLCARD (null);
- peekCP = parseTypdefsOrMgrlvlovrs ();
- }
- }
- parseQRYDSC (netResultSet.netCursor_);
-
- peekCP = peekCodePoint();
- while (peekCP == CodePoint.QRYDTA) {
- parseQRYDTA (netResultSet);
- peekCP = peekCodePoint();
- }
-
- if (peekCP == CodePoint.SQLCARD) {
- NetSqlca netSqlca = parseSQLCARD (null);
- statementI.completeSqlca (netSqlca);
- peekCP = peekCodePoint();
- }
-
- if (peekCP == CodePoint.ENDQRYRM)
- parseEndQuery (netResultSet);
-
- statementI.completeOpenQuery (sqlca, netResultSet);
- }
-
- protected void parseEndQuery (ResultSetCallbackInterface resultSetI) throws DisconnectException
- {
- parseENDQRYRM (resultSetI);
- parseTypdefsOrMgrlvlovrs ();
- NetSqlca netSqlca = parseSQLCARD (null);
- resultSetI.earlyCloseComplete (netSqlca);
- }
-
- void parseOpenQueryFailure (StatementCallbackInterface statementI) throws DisconnectException
- {
- parseOPNQFLRM (statementI);
- parseTypdefsOrMgrlvlovrs ();
- NetSqlca netSqlca = parseSQLCARD (null);
- statementI.completeOpenQuery (netSqlca, null);
- }
-
- void parsePrepareError (StatementCallbackInterface statement) throws DisconnectException
- {
- int peekCP = peekCodePoint();
- switch (peekCP) {
- case CodePoint.ABNUOWRM: {
- NetSqlca sqlca = parseAbnormalEndUow (statement.getConnectionCallbackInterface());
- statement.completeSqlca (sqlca);
- break;
- }
- case CodePoint.CMDCHKRM:
- parseCMDCHKRM();
- break;
- case CodePoint.DTAMCHRM:
- parseDTAMCHRM();
- break;
- case CodePoint.OBJNSPRM:
- parseOBJNSPRM();
- break;
- case CodePoint.RDBNACRM:
- parseRDBNACRM();
- break;
- case CodePoint.SQLERRRM: {
- NetSqlca sqlca = parseSqlErrorCondition();
- statement.completeSqlca (sqlca);
- break;
- }
- default:
- parseCommonError (peekCP);
- }
- }
-
- void parseExecuteImmediateError (StatementCallbackInterface statement) throws DisconnectException
- {
- int peekCP = peekCodePoint();
- switch (peekCP) {
- case CodePoint.ABNUOWRM: {
- NetSqlca sqlca = parseAbnormalEndUow (statement.getConnectionCallbackInterface());
- statement.completeSqlca (sqlca);
- break;
- }
- case CodePoint.CMDCHKRM:
- parseCMDCHKRM();
- break;
- case CodePoint.DTAMCHRM:
- parseDTAMCHRM();
- break;
- case CodePoint.OBJNSPRM:
- parseOBJNSPRM();
- break;
- case CodePoint.RDBNACRM:
- parseRDBNACRM();
- break;
- case CodePoint.SQLERRRM:{
- NetSqlca sqlca = parseSqlErrorCondition();
- statement.completeSqlca (sqlca);
- break;
- }
- default:
- parseCommonError (peekCP);
- break;
- }
- }
-
-
- void parseDescribeError (StatementCallbackInterface statement) throws DisconnectException
- {
- int peekCP = peekCodePoint();
- switch (peekCP) {
- case CodePoint.ABNUOWRM: {
- NetSqlca sqlca = parseAbnormalEndUow (statement.getConnectionCallbackInterface());
- statement.completeSqlca (sqlca);
- break;
- }
- case CodePoint.CMDCHKRM:
- parseCMDCHKRM();
- break;
- case CodePoint.RDBNACRM:
- parseRDBNACRM();
- break;
- case CodePoint.SQLERRRM: {
- NetSqlca sqlca = parseSqlErrorCondition();
- statement.completeSqlca (sqlca);
- break;
- }
- default:
- parseCommonError (peekCP);
- }
- }
-
-
- void parseOpenQueryError (StatementCallbackInterface statementI) throws DisconnectException
- {
- int peekCP = peekCodePoint();
- switch (peekCP) {
- case CodePoint.ABNUOWRM: {
- NetSqlca sqlca = parseAbnormalEndUow (statementI.getConnectionCallbackInterface());
- statementI.completeSqlca (sqlca);
- break;
- }
- case CodePoint.CMDCHKRM:
- parseCMDCHKRM();
- break;
- case CodePoint.DTAMCHRM:
- parseDTAMCHRM();
- break;
- case CodePoint.OBJNSPRM:
- parseOBJNSPRM();
- break;
- case CodePoint.QRYPOPRM:
- parseQRYPOPRM ();
- break;
- case CodePoint.RDBNACRM:
- parseRDBNACRM();
- break;
- default:
- parseCommonError (peekCP);
- }
- }
-
- void parseExecuteError (StatementCallbackInterface statementI) throws DisconnectException
- {
- int peekCP = peekCodePoint();
- switch (peekCP) {
- case CodePoint.ABNUOWRM: {
- NetSqlca sqlca = parseAbnormalEndUow (statementI.getConnectionCallbackInterface());
- statementI.completeSqlca (sqlca);
- break;
- }
- case CodePoint.CMDCHKRM:
- parseCMDCHKRM();
- break;
- case CodePoint.DTAMCHRM:
- parseDTAMCHRM();
- break;
- case CodePoint.OBJNSPRM:
- parseOBJNSPRM();
- break;
- case CodePoint.RDBNACRM:
- parseRDBNACRM();
- break;
- case CodePoint.SQLERRRM: {
- NetSqlca sqlca = parseSqlErrorCondition();
- statementI.completeSqlca (sqlca);
- break;
- }
- default:
- parseCommonError (peekCP);
- break;
- }
- }
-
- void parseExecuteSetStatementError (StatementCallbackInterface statement) throws DisconnectException
- {
- int peekCP = peekCodePoint();
- switch (peekCP) {
- case CodePoint.ABNUOWRM: {
- NetSqlca sqlca = parseAbnormalEndUow (statement.getConnectionCallbackInterface());
- statement.completeSqlca (sqlca);
- break;
- }
- case CodePoint.CMDCHKRM:
- parseCMDCHKRM();
- break;
- case CodePoint.DTAMCHRM:
- parseDTAMCHRM();
- break;
- case CodePoint.OBJNSPRM:
- parseOBJNSPRM();
- break;
- case CodePoint.RDBNACRM:
- parseRDBNACRM();
- break;
- case CodePoint.SQLERRRM: {
- NetSqlca sqlca = parseSqlErrorCondition();
- statement.completeSqlca (sqlca);
- break;
- }
- default:
- parseCommonError (peekCP);
- break;
- }
- }
-
-
- //-----------------------------parse DDM Reply Messages-----------------------
-
- // Open Query Complete Reply Message indicates to the requester that
- // an OPNQRY or EXCSQLSTT command completed normally and that the query
- // process has been initiated. It also indicates the type of query protocol
- // and cursor used for the query.
- // When an EXCSQLSTT contains an SQL statement that invokes a stored procedure,
- // and the procedure completes, an OPNQRYRM is returned for each answer set.
- protected NetResultSet parseOPNQRYRM (StatementCallbackInterface statementI) throws DisconnectException
- {
- // these need to be initialized to the correct default values.
- int svrcod = CodePoint.SVRCOD_INFO;
- boolean svrcodReceived = false;
- int qryprctyp = 0;
- boolean qryprctypReceived = false;
- int sqlcsrhld = 0xF0; // 0xF0 is false (default), 0xF1 is true.
- boolean sqlcsrhldReceived = false;
- int qryattscr = 0xF0; // 0xF0 is false (default), 0xF1 is true.
- boolean qryattscrReceived = false;
- int qryattsns = CodePoint.QRYUNK;
- boolean qryattsnsReceived = false;
- int qryattupd = CodePoint.QRYUNK;
- boolean qryattupdReceived = false;
- long qryinsid = 0;
- boolean qryinsidReceived = false;
-
-
- int qryattset = 0xF0; // 0xF0 is false (default), 0xF1 is true.
- boolean qryattsetReceived = false;
-
- parseLengthAndMatchCodePoint (CodePoint.OPNQRYRM);
- //pushLengthOnCollectionStack();
- int ddmLength = getDdmLength();
- ensureBLayerDataInBuffer (ddmLength);
- int peekCP = peekCodePoint();
- int length = 0;
-
- //while (peekCP != Reply.END_OF_COLLECTION) {
- while (ddmLength > 0) {
-
- boolean foundInPass = false;
-
- if (peekCP == CodePoint.SVRCOD) {
- foundInPass = true;
- svrcodReceived = checkAndGetReceivedFlag (svrcodReceived);
- length = peekedLength_;
- svrcod = parseFastSVRCOD (CodePoint.SVRCOD_INFO, CodePoint.SVRCOD_SESDMG);
- ddmLength = adjustDdmLength (ddmLength, length);
- peekCP = peekCodePoint();
- }
+ // Parse the Result Set Summary Component which consists of a
+ // Result Set Reply Message, SQLCARD or SQLDTARD, and an SQL Result Set
+ // Reply data object. Also check for possible TYPDEF overrides before the
+ // OBJDSSs.
+ // This method returns an ArrayList of generated sections which contain the
+ // package and section information for the result sets which were opened on the
+ // server.
+
+ // the result set summary component consists of a result set reply message.
+ java.util.ArrayList sectionAL = parseRSLSETRM();
+
+ // following the RSLSETRM is an SQLCARD or an SQLDTARD. check for a
+ // TYPDEFNAM or TYPDEFOVR before looking for these objects.
+ int peekCP = parseTypdefsOrMgrlvlovrs();
+
+ // The SQLCARD and the SQLDTARD are mutually exclusive.
+ // The SQLDTARD is returned if the stored procedure had parameters.
+ // (Note: the SQLDTARD contains an sqlca also. this is the sqlca for the
+ // stored procedure call.
+ NetSqldta netSqldta = null;
+ NetSqlca netSqlca = null;
+ if (peekCP == CodePoint.SQLCARD) {
+ netSqlca = parseSQLCARD(null);
+ } else {
+ // keep the PreparedStatementCallbackInterface, since only preparedstatement and callablestatement
+ // has parameters or singleton select which translates to sqldtard.
+ netSqldta = new NetSqldta(netAgent_);
+ netSqlca = parseSQLDTARD(netSqldta);
+ }
- if (peekCP == CodePoint.QRYPRCTYP) {
- foundInPass = true;
- qryprctypReceived = checkAndGetReceivedFlag (qryprctypReceived);
- length = peekedLength_;
- qryprctyp = parseFastQRYPRCTYP();
- ddmLength = adjustDdmLength (ddmLength, length);
- peekCP = peekCodePoint();
- }
+ // check for a possible TYPDEFNAM or TYPDEFOVR
+ // before the SQL Result Set Reply Data object
+ peekCP = parseTypdefsOrMgrlvlovrs();
+
+ int numberOfResultSets = parseSQLRSLRD(sectionAL);
+
+ // The result set summary component parsed above indicated how many result sets were opened
+ // by the stored pocedure call. It contained section information for
+ // each of these result sets. Loop through the section array and
+ // parse the result set component for each of the retunred result sets.
+ NetResultSet[] resultSets = new NetResultSet[numberOfResultSets];
+ for (int i = 0; i < numberOfResultSets; i++) {
+ // parse the result set component of the stored procedure reply.
+ NetResultSet netResultSet = parseResultSetCursor(statementI, (Section) sectionAL.get(i));
+ resultSets[i] = netResultSet;
+ }
- if (peekCP == CodePoint.SQLCSRHLD) {
- // Indicates whether the requester specified the HOLD option.
- // When specified, the cursor is not closed upon execution of a commit operation.
- foundInPass = true;
- sqlcsrhldReceived = checkAndGetReceivedFlag (sqlcsrhldReceived);
- length = peekedLength_;
- sqlcsrhld = parseFastSQLCSRHLD();
- ddmLength = adjustDdmLength (ddmLength, length);
+ // LOBs may have been returned for one of the stored procedure parameters so
+ // check for any externalized data.
peekCP = peekCodePoint();
- }
+ while (peekCP == CodePoint.EXTDTA) {
+ copyEXTDTA(netSqldta);
+ peekCP = peekCodePoint();
+ }
+ statementI.completeExecuteCall(netSqlca, netSqldta, resultSets);
+ }
- if (peekCP == CodePoint.QRYATTSCR) {
- foundInPass = true;
- qryattscrReceived = checkAndGetReceivedFlag (qryattscrReceived);
- length = peekedLength_;
- qryattscr = parseFastQRYATTSCR();
- ddmLength = adjustDdmLength (ddmLength, length);
- peekCP = peekCodePoint();
- }
+ // Parse the Result Set component of the reply for a stored procedure
+ // call which returns result sets.
+ // The Result Set component consists of an Open Query Reply Message
+ // followed by an optional SQLCARD, followed by an optional
+ // SQL Column Information Reply data object, followed by a Query Descriptor.
+ // There may also be Query Data or an End of Query Reply Message.
+ protected NetResultSet parseResultSetCursor(StatementCallbackInterface statementI,
+ Section section) throws DisconnectException {
+ // The first item returne is an OPNQRYRM.
+ NetResultSet netResultSet = parseOPNQRYRM(statementI);
+
+ // The next to be returned is an OBJDSS so check for any TYPDEF overrides.
+ int peekCP = parseTypdefsOrMgrlvlovrs();
+
+ // An SQLCARD may be returned if there were any warnings on the OPEN.
+ NetSqlca netSqlca = null;
+ if (peekCP == CodePoint.SQLCARD) {
+ netSqlca = parseSQLCARD(null);
+ peekCP = parseTypdefsOrMgrlvlovrs();
+ }
- if (peekCP == CodePoint.QRYATTSNS) {
- foundInPass = true;
- qryattsnsReceived = checkAndGetReceivedFlag (qryattsnsReceived);
- length = peekedLength_;
- qryattsns = parseFastQRYATTSNS();
- ddmLength = adjustDdmLength (ddmLength, length);
- peekCP = peekCodePoint();
- }
+ // the SQLCINRD contains SQLDA like information for the result set.
+ ColumnMetaData resultSetMetaData = null;
+ if (peekCP == CodePoint.SQLCINRD) {
+ resultSetMetaData = parseSQLCINRD();
+ peekCP = parseTypdefsOrMgrlvlovrs();
+ }
- if (peekCP == CodePoint.QRYATTUPD) {
- foundInPass = true;
- qryattupdReceived = checkAndGetReceivedFlag (qryattupdReceived);
- length = peekedLength_;
- qryattupd = parseFastQRYATTUPD();
- ddmLength = adjustDdmLength (ddmLength, length);
- peekCP = peekCodePoint();
- }
+ // A Query Descriptor must be present.
+ // We cannot cache the cursor if result set is returned from a stored procedure, so
+ // there is no cached cursor to use here.
+ parseQRYDSC(netResultSet.netCursor_);
+ peekCP = peekCodePoint();
+ statementI.completeExecuteCallOpenQuery(netSqlca, netResultSet, resultSetMetaData, section);
+
+ // Depending on the blocking rules, QRYDTA may have been returned on the open.
+ while (peekCP == CodePoint.QRYDTA) {
+ parseQRYDTA(netResultSet);
+ peekCP = peekCodePoint();
+ }
- if (peekCP == CodePoint.QRYINSID) {
- foundInPass = true;
- qryinsidReceived = checkAndGetReceivedFlag (qryinsidReceived);
- length = peekedLength_;
- qryinsid = parseFastQRYINSID ();
- ddmLength = adjustDdmLength (ddmLength, length);
- peekCP = peekCodePoint();
- }
+ // Under some circumstances, the server may have closed the cursor.
+ // This will be indicated by an ENDQRYRM.
+ if (peekCP == CodePoint.ENDQRYRM) {
+ parseEndQuery((ResultSetCallbackInterface) netResultSet);
+ }
+
+ return netResultSet;
+ }
+
+ protected void parseOpenQuery(StatementCallbackInterface statementI) throws DisconnectException {
+ NetResultSet netResultSet = parseOPNQRYRM(statementI);
+
+ NetSqlca sqlca = null;
+ int peekCP = peekCodePoint();
+ if (peekCP != CodePoint.QRYDSC) {
+
+ peekCP = parseTypdefsOrMgrlvlovrs();
+
+ if (peekCP == CodePoint.SQLDARD) {
+ ColumnMetaData columnMetaData = new ColumnMetaData(netAgent_.logWriter_);
+ NetSqlca netSqlca = parseSQLDARD(columnMetaData, false); // false means do not skip SQLDARD bytes
+
+ //For java stored procedure, we got the resultSetMetaData from server,
+ //Do we need to save the resultSetMetaData and propagate netSqlca?
+ //The following statement are doing the both, but it do more than
+ //we want. It also mark the completion of Prepare statement.
+ //
+ // this will override the same call made from parsePrepareDescribe
+ // this will not work, this is not the DA for the stored proc params
+ statementI.completePrepareDescribeOutput(columnMetaData, netSqlca);
+ peekCP = parseTypdefsOrMgrlvlovrs();
+ }
+ // check if the DARD is mutually exclusive with CARD, if so, then the following if should be an elese
+
+ if (peekCP == CodePoint.SQLCARD) {
+ sqlca = parseSQLCARD(null);
+ peekCP = parseTypdefsOrMgrlvlovrs();
+ }
+ }
+ parseQRYDSC(netResultSet.netCursor_);
- if (peekCP == CodePoint.QRYATTSET) {
- foundInPass = true;
- qryattsetReceived = checkAndGetReceivedFlag (qryattsetReceived);
- length = peekedLength_;
- qryattset = parseFastQRYATTSET();
- ddmLength = adjustDdmLength (ddmLength, length);
peekCP = peekCodePoint();
- }
+ while (peekCP == CodePoint.QRYDTA) {
+ parseQRYDTA(netResultSet);
+ peekCP = peekCodePoint();
+ }
+ if (peekCP == CodePoint.SQLCARD) {
+ NetSqlca netSqlca = parseSQLCARD(null);
+ statementI.completeSqlca(netSqlca);
+ peekCP = peekCodePoint();
+ }
- if (!foundInPass)
- doPrmnsprmSemantics (peekCP);
+ if (peekCP == CodePoint.ENDQRYRM) {
+ parseEndQuery(netResultSet);
+ }
+ statementI.completeOpenQuery(sqlca, netResultSet);
}
- checkRequiredObjects (svrcodReceived, qryprctypReceived, qryinsidReceived);
- netAgent_.setSvrcod (svrcod);
-
- // hack for now until event methods are used below
- Statement statement = (Statement) statementI;
-
- // if there is a cached Cursor object, then use the cached cursor object.
- NetResultSet rs = null;
- if (statement.cachedCursor_ != null) {
- statement.cachedCursor_.resetDataBuffer();
- ((NetCursor)statement.cachedCursor_).extdtaData_.clear();
- rs = new NetResultSet (netAgent_,
- (NetStatement) statement.materialStatement_,
- statement.cachedCursor_,
- //qryprctyp, //protocolType, CodePoint.FIXROWPRC | CodePoint.LMTBLKPRC
- sqlcsrhld, //holdOption, 0xF0 for false (default) | 0xF1 for true.
- qryattscr, //scrollOption, 0xF0 for false (default) | 0xF1 for true.
- qryattsns, //sensitivity, CodePoint.QRYUNK | CodePoint.QRYINS
- qryattset,
- qryinsid, //instanceIdentifier, 0 (if not returned, check default) or number
- calculateResultSetType (qryattscr,qryattsns,statement.resultSetType_),
- calculateResultSetConcurrency (qryattupd,statement.resultSetConcurrency_),
- calculateResultSetHoldability (sqlcsrhld)
- );
- }
- else
- rs = new NetResultSet (netAgent_,
- (NetStatement) statement.materialStatement_,
- new NetCursor (netAgent_, qryprctyp),
- //qryprctyp, //protocolType, CodePoint.FIXROWPRC | CodePoint.LMTBLKPRC
- sqlcsrhld, //holdOption, 0xF0 for false (default) | 0xF1 for true.
- qryattscr, //scrollOption, 0xF0 for false (default) | 0xF1 for true.
- qryattsns, //sensitivity, CodePoint.QRYUNK | CodePoint.QRYINS
- qryattset,
- qryinsid, //instanceIdentifier, 0 (if not returned, check default) or number
- calculateResultSetType (qryattscr,qryattsns,statement.resultSetType_),
- calculateResultSetConcurrency (qryattupd,statement.resultSetConcurrency_),
- calculateResultSetHoldability (sqlcsrhld)
- );
-
- return rs;
- }
-
-
- // Also called by NetResultSetReply subclass.
- // The End of Query Reply Message indicates that the query process has
- // terminated in such a manner that the query or result set is now closed.
- // It cannot be resumed with the CNTQRY command or closed with the CLSQRY command.
- // The ENDQRYRM is always followed by an SQLCARD.
- protected void parseENDQRYRM (ResultSetCallbackInterface resultSetI) throws DisconnectException
- {
- boolean svrcodReceived = false;
- int svrcod = CodePoint.SVRCOD_INFO;
- boolean rdbnamReceived = false;
- String rdbnam = null;
-
- parseLengthAndMatchCodePoint (CodePoint.ENDQRYRM);
- pushLengthOnCollectionStack();
- int peekCP = peekCodePoint();
-
- while (peekCP != Reply.END_OF_COLLECTION) {
-
- boolean foundInPass = false;
-
- if (peekCP == CodePoint.SVRCOD) {
- foundInPass = true;
- svrcodReceived = checkAndGetReceivedFlag (svrcodReceived);
- svrcod = parseSVRCOD (CodePoint.SVRCOD_WARNING, CodePoint.SVRCOD_ERROR);
- peekCP = peekCodePoint();
- }
+ protected void parseEndQuery(ResultSetCallbackInterface resultSetI) throws DisconnectException {
+ parseENDQRYRM(resultSetI);
+ parseTypdefsOrMgrlvlovrs();
+ NetSqlca netSqlca = parseSQLCARD(null);
+ resultSetI.earlyCloseComplete(netSqlca);
+ }
+
+ void parseOpenQueryFailure(StatementCallbackInterface statementI) throws DisconnectException {
+ parseOPNQFLRM(statementI);
+ parseTypdefsOrMgrlvlovrs();
+ NetSqlca netSqlca = parseSQLCARD(null);
+ statementI.completeOpenQuery(netSqlca, null);
+ }
+
+ void parsePrepareError(StatementCallbackInterface statement) throws DisconnectException {
+ int peekCP = peekCodePoint();
+ switch (peekCP) {
+ case CodePoint.ABNUOWRM:
+ {
+ NetSqlca sqlca = parseAbnormalEndUow(statement.getConnectionCallbackInterface());
+ statement.completeSqlca(sqlca);
+ break;
+ }
+ case CodePoint.CMDCHKRM:
+ parseCMDCHKRM();
+ break;
+ case CodePoint.DTAMCHRM:
+ parseDTAMCHRM();
+ break;
+ case CodePoint.OBJNSPRM:
+ parseOBJNSPRM();
+ break;
+ case CodePoint.RDBNACRM:
+ parseRDBNACRM();
+ break;
+ case CodePoint.SQLERRRM:
+ {
+ NetSqlca sqlca = parseSqlErrorCondition();
+ statement.completeSqlca(sqlca);
+ break;
+ }
+ default:
+ parseCommonError(peekCP);
+ }
+ }
- if (peekCP == CodePoint.RDBNAM) {
- foundInPass = true;
- rdbnamReceived = checkAndGetReceivedFlag (rdbnamReceived);
- rdbnam = parseRDBNAM (true);
- peekCP = peekCodePoint();
- }
- if (!foundInPass)
- doPrmnsprmSemantics (peekCP);
-
- }
- popCollectionStack();
- checkRequiredObjects (svrcodReceived);
-
- netAgent_.setSvrcod (svrcod);
-
- }
-
-
- // Query Previously Opened Reply Message is issued when an
- // OPNQRY command is issued for a query that is already open.
- // A previous OPNQRY command might have opened the query
- // which may not be closed.
- // PROTOCOL Architects an SQLSTATE of 58008 or 58009.
- //
- // Messages
- // SQLSTATE : 58009
- // Execution failed due to a distribution protocol error that caused deallocation of the conversation.
- // SQLCODE : -30020
- // Execution failed because of a Distributed Protocol
- // Error that will affect the successful execution of subsequent
- // commands and SQL statements: Reason Code <reason-code>.
- // Some possible reason codes include:
- // 121C Indicates that the user is not authorized to perform the requested command.
- // 1232 The command could not be completed because of a permanent error.
- // In most cases, the server will be in the process of an abend.
- // 220A The target server has received an invalid data description.
- // If a user SQLDA is specified, ensure that the fields are
- // initialized correctly. Also, ensure that the length does not
- // exceed the maximum allowed length for the data type being used.
- //
- // The command or statement cannot be processed. The current
- // transaction is rolled back and the application is disconnected
- // from the remote database.
- //
- //
- // Returned from Server:
- // SVRCOD - required (8 - ERROR)
- // RDBNAM - required
- // PKGNAMCSN - required
- // SRVDGN - optional
- //
- private void parseQRYPOPRM () throws DisconnectException
- {
- boolean svrcodReceived = false;
- int svrcod = CodePoint.SVRCOD_INFO;
- boolean rdbnamReceived = false;
- String rdbnam = null;
- boolean pkgnamcsnReceived = false;
- Object pkgnamcsn = null;
-
- parseLengthAndMatchCodePoint (CodePoint.QRYPOPRM);
- pushLengthOnCollectionStack();
- int peekCP = peekCodePoint();
-
- while (peekCP != Reply.END_OF_COLLECTION) {
-
- boolean foundInPass = false;
-
- if (peekCP == CodePoint.SVRCOD) {
- foundInPass = true;
- svrcodReceived = checkAndGetReceivedFlag (svrcodReceived);
- svrcod = parseSVRCOD (CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
- peekCP = peekCodePoint();
- }
+ void parseExecuteImmediateError(StatementCallbackInterface statement) throws DisconnectException {
+ int peekCP = peekCodePoint();
+ switch (peekCP) {
+ case CodePoint.ABNUOWRM:
+ {
+ NetSqlca sqlca = parseAbnormalEndUow(statement.getConnectionCallbackInterface());
+ statement.completeSqlca(sqlca);
+ break;
+ }
+ case CodePoint.CMDCHKRM:
+ parseCMDCHKRM();
+ break;
+ case CodePoint.DTAMCHRM:
+ parseDTAMCHRM();
+ break;
+ case CodePoint.OBJNSPRM:
+ parseOBJNSPRM();
+ break;
+ case CodePoint.RDBNACRM:
+ parseRDBNACRM();
+ break;
+ case CodePoint.SQLERRRM:
+ {
+ NetSqlca sqlca = parseSqlErrorCondition();
+ statement.completeSqlca(sqlca);
+ break;
+ }
+ default:
+ parseCommonError(peekCP);
+ break;
+ }
+ }
- if (peekCP == CodePoint.RDBNAM) {
- foundInPass = true;
- rdbnamReceived = checkAndGetReceivedFlag (rdbnamReceived);
- rdbnam = parseRDBNAM (true);
- peekCP = peekCodePoint();
- }
- if (peekCP == CodePoint.PKGNAMCSN) {
- foundInPass = true;
- pkgnamcsnReceived = checkAndGetReceivedFlag (pkgnamcsnReceived);
- pkgnamcsn = parsePKGNAMCSN (true);
- peekCP = peekCodePoint();
- }
- if (!foundInPass)
- doPrmnsprmSemantics (peekCP);
+ void parseDescribeError(StatementCallbackInterface statement) throws DisconnectException {
+ int peekCP = peekCodePoint();
+ switch (peekCP) {
+ case CodePoint.ABNUOWRM:
+ {
+ NetSqlca sqlca = parseAbnormalEndUow(statement.getConnectionCallbackInterface());
+ statement.completeSqlca(sqlca);
+ break;
+ }
+ case CodePoint.CMDCHKRM:
+ parseCMDCHKRM();
+ break;
+ case CodePoint.RDBNACRM:
+ parseRDBNACRM();
+ break;
+ case CodePoint.SQLERRRM:
+ {
+ NetSqlca sqlca = parseSqlErrorCondition();
+ statement.completeSqlca(sqlca);
+ break;
+ }
+ default:
+ parseCommonError(peekCP);
+ }
+ }
+
+ void parseOpenQueryError(StatementCallbackInterface statementI) throws DisconnectException {
+ int peekCP = peekCodePoint();
+ switch (peekCP) {
+ case CodePoint.ABNUOWRM:
+ {
+ NetSqlca sqlca = parseAbnormalEndUow(statementI.getConnectionCallbackInterface());
+ statementI.completeSqlca(sqlca);
+ break;
+ }
+ case CodePoint.CMDCHKRM:
+ parseCMDCHKRM();
+ break;
+ case CodePoint.DTAMCHRM:
+ parseDTAMCHRM();
+ break;
+ case CodePoint.OBJNSPRM:
+ parseOBJNSPRM();
+ break;
+ case CodePoint.QRYPOPRM:
+ parseQRYPOPRM();
+ break;
+ case CodePoint.RDBNACRM:
+ parseRDBNACRM();
+ break;
+ default:
+ parseCommonError(peekCP);
+ }
}
- popCollectionStack();
- checkRequiredObjects (svrcodReceived,
- rdbnamReceived,
- pkgnamcsnReceived);
-
- netAgent_.setSvrcod (svrcod);
- agent_.accumulateChainBreakingReadExceptionAndThrow (new DisconnectException (
- agent_,
- "Execution failed due to a distribution protocol error that caused " +
- "deallocation of the conversation. " +
- "An Open Query Command was issued for a query which was already open.",
- SqlState._58009));
- }
-
- // Open Query Failure (OPNQFLRM) Reply Message indicates that the
- // OPNQRY command failed to open the query. The reason that the
- // target relational database was unable to open the query is reported in an
- // SQLCARD reply data object.
- // Whenever an OPNQFLRM is returned, an SQLCARD object must also be returned
- // following the OPNQFLRM.
- //
- // Returned from Server:
- // SVRCOD - required (8 - ERROR)
- // RDBNAM - required
- // SRVDGN - optional
- private void parseOPNQFLRM (StatementCallbackInterface statement) throws DisconnectException
- {
- boolean svrcodReceived = false;
- int svrcod = CodePoint.SVRCOD_INFO;
- boolean rdbnamReceived = false;
- String rdbnam = null;
-
- parseLengthAndMatchCodePoint (CodePoint.OPNQFLRM);
- pushLengthOnCollectionStack();
- int peekCP = peekCodePoint();
-
- while (peekCP != Reply.END_OF_COLLECTION) {
-
- boolean foundInPass = false;
-
- if (peekCP == CodePoint.SVRCOD) {
- foundInPass = true;
- svrcodReceived = checkAndGetReceivedFlag (svrcodReceived);
- svrcod = parseSVRCOD (CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
- peekCP = peekCodePoint();
- }
- if (peekCP == CodePoint.RDBNAM) {
- // skip the rdbnam since it doesn't tell us anything new.
- // there is no way to return it to the application anyway.
- // not having to convert this to a string is a time saver also.
- foundInPass = true;
- rdbnamReceived = checkAndGetReceivedFlag (rdbnamReceived);
- rdbnam = parseRDBNAM (true);
- peekCP = peekCodePoint();
- }
- if (!foundInPass)
- doPrmnsprmSemantics (peekCP);
-
- }
- popCollectionStack();
- checkRequiredObjects (svrcodReceived, rdbnamReceived);
-
- netAgent_.setSvrcod (svrcod);
-
- // get SQLSTATE from SQLCARD...
- }
-
- // RDB Result Set Reply Message (RSLSETRM) indicates that an
- // EXCSQLSTT command invoked a stored procedure, that the execution
- // of the stored procedure generated one or more result sets, and
- // additional information aobut these result sets follows the SQLCARD and
- // SQLDTARD in the reply data of the response
- //
- // Returned from Server:
- // SVRCOD - required (0 INFO)
- // PKGSNLST - required
- // SRVDGN - optional
- protected java.util.ArrayList parseRSLSETRM () throws DisconnectException
- {
- boolean svrcodReceived = false;
- int svrcod = CodePoint.SVRCOD_INFO;
- boolean pkgsnlstReceived = false;
- java.util.ArrayList pkgsnlst = null;
-
- parseLengthAndMatchCodePoint (CodePoint.RSLSETRM);
- pushLengthOnCollectionStack();
- int peekCP = peekCodePoint();
-
- while (peekCP != Reply.END_OF_COLLECTION) {
-
- boolean foundInPass = false;
-
- if (peekCP == CodePoint.SVRCOD) {
- foundInPass = true;
- svrcodReceived = checkAndGetReceivedFlag (svrcodReceived);
- svrcod = parseSVRCOD (CodePoint.SVRCOD_INFO, CodePoint.SVRCOD_INFO);
- peekCP = peekCodePoint();
- }
+ void parseExecuteError(StatementCallbackInterface statementI) throws DisconnectException {
+ int peekCP = peekCodePoint();
+ switch (peekCP) {
+ case CodePoint.ABNUOWRM:
+ {
+ NetSqlca sqlca = parseAbnormalEndUow(statementI.getConnectionCallbackInterface());
+ statementI.completeSqlca(sqlca);
+ break;
+ }
+ case CodePoint.CMDCHKRM:
+ parseCMDCHKRM();
+ break;
+ case CodePoint.DTAMCHRM:
+ parseDTAMCHRM();
+ break;
+ case CodePoint.OBJNSPRM:
+ parseOBJNSPRM();
+ break;
+ case CodePoint.RDBNACRM:
+ parseRDBNACRM();
+ break;
+ case CodePoint.SQLERRRM:
+ {
+ NetSqlca sqlca = parseSqlErrorCondition();
+ statementI.completeSqlca(sqlca);
+ break;
+ }
+ default:
+ parseCommonError(peekCP);
+ break;
+ }
+ }
- if (peekCP == CodePoint.PKGSNLST) {
- // contain repeatable PKGNAMCSN
- foundInPass = true;
- pkgsnlstReceived = checkAndGetReceivedFlag (pkgsnlstReceived);
- pkgsnlst = parsePKGSNLST();
- peekCP = peekCodePoint();
- }
+ void parseExecuteSetStatementError(StatementCallbackInterface statement) throws DisconnectException {
+ int peekCP = peekCodePoint();
+ switch (peekCP) {
+ case CodePoint.ABNUOWRM:
+ {
+ NetSqlca sqlca = parseAbnormalEndUow(statement.getConnectionCallbackInterface());
+ statement.completeSqlca(sqlca);
+ break;
+ }
+ case CodePoint.CMDCHKRM:
+ parseCMDCHKRM();
+ break;
+ case CodePoint.DTAMCHRM:
+ parseDTAMCHRM();
+ break;
+ case CodePoint.OBJNSPRM:
+ parseOBJNSPRM();
+ break;
+ case CodePoint.RDBNACRM:
+ parseRDBNACRM();
+ break;
+ case CodePoint.SQLERRRM:
+ {
+ NetSqlca sqlca = parseSqlErrorCondition();
+ statement.completeSqlca(sqlca);
+ break;
+ }
+ default:
+ parseCommonError(peekCP);
+ break;
+ }
+ }
+
+
+ //-----------------------------parse DDM Reply Messages-----------------------
+
+ // Open Query Complete Reply Message indicates to the requester that
+ // an OPNQRY or EXCSQLSTT command completed normally and that the query
+ // process has been initiated. It also indicates the type of query protocol
+ // and cursor used for the query.
+ // When an EXCSQLSTT contains an SQL statement that invokes a stored procedure,
+ // and the procedure completes, an OPNQRYRM is returned for each answer set.
+ protected NetResultSet parseOPNQRYRM(StatementCallbackInterface statementI) throws DisconnectException {
+ // these need to be initialized to the correct default values.
+ int svrcod = CodePoint.SVRCOD_INFO;
+ boolean svrcodReceived = false;
+ int qryprctyp = 0;
+ boolean qryprctypReceived = false;
+ int sqlcsrhld = 0xF0; // 0xF0 is false (default), 0xF1 is true.
+ boolean sqlcsrhldReceived = false;
+ int qryattscr = 0xF0; // 0xF0 is false (default), 0xF1 is true.
+ boolean qryattscrReceived = false;
+ int qryattsns = CodePoint.QRYUNK;
+ boolean qryattsnsReceived = false;
+ int qryattupd = CodePoint.QRYUNK;
+ boolean qryattupdReceived = false;
+ long qryinsid = 0;
+ boolean qryinsidReceived = false;
+
+
+ int qryattset = 0xF0; // 0xF0 is false (default), 0xF1 is true.
+ boolean qryattsetReceived = false;
+
+ parseLengthAndMatchCodePoint(CodePoint.OPNQRYRM);
+ //pushLengthOnCollectionStack();
+ int ddmLength = getDdmLength();
+ ensureBLayerDataInBuffer(ddmLength);
+ int peekCP = peekCodePoint();
+ int length = 0;
+
+ //while (peekCP != Reply.END_OF_COLLECTION) {
+ while (ddmLength > 0) {
+
+ boolean foundInPass = false;
+
+ if (peekCP == CodePoint.SVRCOD) {
+ foundInPass = true;
+ svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
+ length = peekedLength_;
+ svrcod = parseFastSVRCOD(CodePoint.SVRCOD_INFO, CodePoint.SVRCOD_SESDMG);
+ ddmLength = adjustDdmLength(ddmLength, length);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.QRYPRCTYP) {
+ foundInPass = true;
+ qryprctypReceived = checkAndGetReceivedFlag(qryprctypReceived);
+ length = peekedLength_;
+ qryprctyp = parseFastQRYPRCTYP();
+ ddmLength = adjustDdmLength(ddmLength, length);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.SQLCSRHLD) {
+ // Indicates whether the requester specified the HOLD option.
+ // When specified, the cursor is not closed upon execution of a commit operation.
+ foundInPass = true;
+ sqlcsrhldReceived = checkAndGetReceivedFlag(sqlcsrhldReceived);
+ length = peekedLength_;
+ sqlcsrhld = parseFastSQLCSRHLD();
+ ddmLength = adjustDdmLength(ddmLength, length);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.QRYATTSCR) {
+ foundInPass = true;
+ qryattscrReceived = checkAndGetReceivedFlag(qryattscrReceived);
+ length = peekedLength_;
+ qryattscr = parseFastQRYATTSCR();
+ ddmLength = adjustDdmLength(ddmLength, length);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.QRYATTSNS) {
+ foundInPass = true;
+ qryattsnsReceived = checkAndGetReceivedFlag(qryattsnsReceived);
+ length = peekedLength_;
+ qryattsns = parseFastQRYATTSNS();
+ ddmLength = adjustDdmLength(ddmLength, length);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.QRYATTUPD) {
+ foundInPass = true;
+ qryattupdReceived = checkAndGetReceivedFlag(qryattupdReceived);
+ length = peekedLength_;
+ qryattupd = parseFastQRYATTUPD();
+ ddmLength = adjustDdmLength(ddmLength, length);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.QRYINSID) {
+ foundInPass = true;
+ qryinsidReceived = checkAndGetReceivedFlag(qryinsidReceived);
+ length = peekedLength_;
+ qryinsid = parseFastQRYINSID();
+ ddmLength = adjustDdmLength(ddmLength, length);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.QRYATTSET) {
+ foundInPass = true;
+ qryattsetReceived = checkAndGetReceivedFlag(qryattsetReceived);
+ length = peekedLength_;
+ qryattset = parseFastQRYATTSET();
+ ddmLength = adjustDdmLength(ddmLength, length);
+ peekCP = peekCodePoint();
+ }
+
+
+ if (!foundInPass) {
+ doPrmnsprmSemantics(peekCP);
+ }
+
+ }
+ checkRequiredObjects(svrcodReceived, qryprctypReceived, qryinsidReceived);
+
+ netAgent_.setSvrcod(svrcod);
+
+ // hack for now until event methods are used below
+ Statement statement = (Statement) statementI;
+
+ // if there is a cached Cursor object, then use the cached cursor object.
+ NetResultSet rs = null;
+ if (statement.cachedCursor_ != null) {
+ statement.cachedCursor_.resetDataBuffer();
+ ((NetCursor) statement.cachedCursor_).extdtaData_.clear();
+ rs = new NetResultSet(netAgent_,
+ (NetStatement) statement.materialStatement_,
+ statement.cachedCursor_,
+ //qryprctyp, //protocolType, CodePoint.FIXROWPRC | CodePoint.LMTBLKPRC
+ sqlcsrhld, //holdOption, 0xF0 for false (default) | 0xF1 for true.
+ qryattscr, //scrollOption, 0xF0 for false (default) | 0xF1 for true.
+ qryattsns, //sensitivity, CodePoint.QRYUNK | CodePoint.QRYINS
+ qryattset,
+ qryinsid, //instanceIdentifier, 0 (if not returned, check default) or number
+ calculateResultSetType(qryattscr, qryattsns, statement.resultSetType_),
+ calculateResultSetConcurrency(qryattupd, statement.resultSetConcurrency_),
+ calculateResultSetHoldability(sqlcsrhld));
+ } else {
+ rs = new NetResultSet(netAgent_,
+ (NetStatement) statement.materialStatement_,
+ new NetCursor(netAgent_, qryprctyp),
+ //qryprctyp, //protocolType, CodePoint.FIXROWPRC | CodePoint.LMTBLKPRC
+ sqlcsrhld, //holdOption, 0xF0 for false (default) | 0xF1 for true.
+ qryattscr, //scrollOption, 0xF0 for false (default) | 0xF1 for true.
+ qryattsns, //sensitivity, CodePoint.QRYUNK | CodePoint.QRYINS
+ qryattset,
+ qryinsid, //instanceIdentifier, 0 (if not returned, check default) or number
+ calculateResultSetType(qryattscr, qryattsns, statement.resultSetType_),
+ calculateResultSetConcurrency(qryattupd, statement.resultSetConcurrency_),
+ calculateResultSetHoldability(sqlcsrhld));
+ }
+
+ return rs;
+ }
+
+
+ // Also called by NetResultSetReply subclass.
+ // The End of Query Reply Message indicates that the query process has
+ // terminated in such a manner that the query or result set is now closed.
+ // It cannot be resumed with the CNTQRY command or closed with the CLSQRY command.
+ // The ENDQRYRM is always followed by an SQLCARD.
+ protected void parseENDQRYRM(ResultSetCallbackInterface resultSetI) throws DisconnectException {
+ boolean svrcodReceived = false;
+ int svrcod = CodePoint.SVRCOD_INFO;
+ boolean rdbnamReceived = false;
+ String rdbnam = null;
+
+ parseLengthAndMatchCodePoint(CodePoint.ENDQRYRM);
+ pushLengthOnCollectionStack();
+ int peekCP = peekCodePoint();
+
+ while (peekCP != Reply.END_OF_COLLECTION) {
+
+ boolean foundInPass = false;
+
+ if (peekCP == CodePoint.SVRCOD) {
+ foundInPass = true;
+ svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
+ svrcod = parseSVRCOD(CodePoint.SVRCOD_WARNING, CodePoint.SVRCOD_ERROR);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.RDBNAM) {
+ foundInPass = true;
+ rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
+ rdbnam = parseRDBNAM(true);
+ peekCP = peekCodePoint();
+ }
+ if (!foundInPass) {
+ doPrmnsprmSemantics(peekCP);
+ }
+
+ }
+ popCollectionStack();
+ checkRequiredObjects(svrcodReceived);
- if (!foundInPass)
- doPrmnsprmSemantics (peekCP);
+ netAgent_.setSvrcod(svrcod);
}
- popCollectionStack();
- checkRequiredObjects (svrcodReceived, pkgsnlstReceived);
- netAgent_.setSvrcod (svrcod);
- return pkgsnlst;
- }
+ // Query Previously Opened Reply Message is issued when an
+ // OPNQRY command is issued for a query that is already open.
+ // A previous OPNQRY command might have opened the query
+ // which may not be closed.
+ // PROTOCOL Architects an SQLSTATE of 58008 or 58009.
+ //
+ // Messages
+ // SQLSTATE : 58009
+ // Execution failed due to a distribution protocol error that caused deallocation of the conversation.
+ // SQLCODE : -30020
+ // Execution failed because of a Distributed Protocol
+ // Error that will affect the successful execution of subsequent
+ // commands and SQL statements: Reason Code <reason-code>.
+ // Some possible reason codes include:
+ // 121C Indicates that the user is not authorized to perform the requested command.
+ // 1232 The command could not be completed because of a permanent error.
+ // In most cases, the server will be in the process of an abend.
+ // 220A The target server has received an invalid data description.
+ // If a user SQLDA is specified, ensure that the fields are
+ // initialized correctly. Also, ensure that the length does not
+ // exceed the maximum allowed length for the data type being used.
+ //
+ // The command or statement cannot be processed. The current
+ // transaction is rolled back and the application is disconnected
+ // from the remote database.
+ //
+ //
+ // Returned from Server:
+ // SVRCOD - required (8 - ERROR)
+ // RDBNAM - required
+ // PKGNAMCSN - required
+ // SRVDGN - optional
+ //
+ private void parseQRYPOPRM() throws DisconnectException {
+ boolean svrcodReceived = false;
+ int svrcod = CodePoint.SVRCOD_INFO;
+ boolean rdbnamReceived = false;
+ String rdbnam = null;
+ boolean pkgnamcsnReceived = false;
+ Object pkgnamcsn = null;
+
+ parseLengthAndMatchCodePoint(CodePoint.QRYPOPRM);
+ pushLengthOnCollectionStack();
+ int peekCP = peekCodePoint();
+
+ while (peekCP != Reply.END_OF_COLLECTION) {
+
+ boolean foundInPass = false;
+
+ if (peekCP == CodePoint.SVRCOD) {
+ foundInPass = true;
+ svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
+ svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.RDBNAM) {
+ foundInPass = true;
+ rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
+ rdbnam = parseRDBNAM(true);
+ peekCP = peekCodePoint();
+ }
+ if (peekCP == CodePoint.PKGNAMCSN) {
+ foundInPass = true;
+ pkgnamcsnReceived = checkAndGetReceivedFlag(pkgnamcsnReceived);
+ pkgnamcsn = parsePKGNAMCSN(true);
+ peekCP = peekCodePoint();
+ }
+
+ if (!foundInPass) {
+ doPrmnsprmSemantics(peekCP);
+ }
- //--------------------- parse DDM Reply Data--------------------------------------
+ }
+ popCollectionStack();
+ checkRequiredObjects(svrcodReceived,
+ rdbnamReceived,
+ pkgnamcsnReceived);
+
+ netAgent_.setSvrcod(svrcod);
+ agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
+ "Execution failed due to a distribution protocol error that caused " +
+ "deallocation of the conversation. " +
+ "An Open Query Command was issued for a query which was already open.",
+ SqlState._58009));
+ }
+
+ // Open Query Failure (OPNQFLRM) Reply Message indicates that the
+ // OPNQRY command failed to open the query. The reason that the
+ // target relational database was unable to open the query is reported in an
+ // SQLCARD reply data object.
+ // Whenever an OPNQFLRM is returned, an SQLCARD object must also be returned
+ // following the OPNQFLRM.
+ //
+ // Returned from Server:
+ // SVRCOD - required (8 - ERROR)
+ // RDBNAM - required
+ // SRVDGN - optional
+ private void parseOPNQFLRM(StatementCallbackInterface statement) throws DisconnectException {
+ boolean svrcodReceived = false;
+ int svrcod = CodePoint.SVRCOD_INFO;
+ boolean rdbnamReceived = false;
+ String rdbnam = null;
+
+ parseLengthAndMatchCodePoint(CodePoint.OPNQFLRM);
+ pushLengthOnCollectionStack();
+ int peekCP = peekCodePoint();
+
+ while (peekCP != Reply.END_OF_COLLECTION) {
+
+ boolean foundInPass = false;
+
+ if (peekCP == CodePoint.SVRCOD) {
+ foundInPass = true;
+ svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
+ svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.RDBNAM) {
+ // skip the rdbnam since it doesn't tell us anything new.
+ // there is no way to return it to the application anyway.
+ // not having to convert this to a string is a time saver also.
+ foundInPass = true;
+ rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
+ rdbnam = parseRDBNAM(true);
+ peekCP = peekCodePoint();
+ }
+ if (!foundInPass) {
+ doPrmnsprmSemantics(peekCP);
+ }
+ }
+ popCollectionStack();
+ checkRequiredObjects(svrcodReceived, rdbnamReceived);
- // SQL Data Reply Data consists of output data from the relational database (RDB)
- // processing of an SQL statement. It also includes a description of the data.
- //
- // Returned from Server:
- // FDODSC - required
- // FDODTA - required
- protected NetSqlca parseSQLDTARD (NetSqldta netSqldta) throws DisconnectException
- {
- boolean fdodscReceived = false;
- boolean fdodtaReceived = false;
+ netAgent_.setSvrcod(svrcod);
- parseLengthAndMatchCodePoint (CodePoint.SQLDTARD);
- pushLengthOnCollectionStack();
+ // get SQLSTATE from SQLCARD...
+ }
- NetSqlca netSqlca = null;
- int peekCP = peekCodePoint();
- while (peekCP != Reply.END_OF_COLLECTION) {
+ // RDB Result Set Reply Message (RSLSETRM) indicates that an
+ // EXCSQLSTT command invoked a stored procedure, that the execution
+ // of the stored procedure generated one or more result sets, and
+ // additional information aobut these result sets follows the SQLCARD and
+ // SQLDTARD in the reply data of the response
+ //
+ // Returned from Server:
+ // SVRCOD - required (0 INFO)
+ // PKGSNLST - required
+ // SRVDGN - optional
+ protected java.util.ArrayList parseRSLSETRM() throws DisconnectException {
+ boolean svrcodReceived = false;
+ int svrcod = CodePoint.SVRCOD_INFO;
+ boolean pkgsnlstReceived = false;
+ java.util.ArrayList pkgsnlst = null;
+
+ parseLengthAndMatchCodePoint(CodePoint.RSLSETRM);
+ pushLengthOnCollectionStack();
+ int peekCP = peekCodePoint();
+
+ while (peekCP != Reply.END_OF_COLLECTION) {
+
+ boolean foundInPass = false;
+
+ if (peekCP == CodePoint.SVRCOD) {
+ foundInPass = true;
+ svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
+ svrcod = parseSVRCOD(CodePoint.SVRCOD_INFO, CodePoint.SVRCOD_INFO);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.PKGSNLST) {
+ // contain repeatable PKGNAMCSN
+ foundInPass = true;
+ pkgsnlstReceived = checkAndGetReceivedFlag(pkgsnlstReceived);
+ pkgsnlst = parsePKGSNLST();
+ peekCP = peekCodePoint();
+ }
+
+ if (!foundInPass) {
+ doPrmnsprmSemantics(peekCP);
+ }
- boolean foundInPass = false;
+ }
+ popCollectionStack();
+ checkRequiredObjects(svrcodReceived, pkgsnlstReceived);
- if (peekCP == CodePoint.FDODSC) {
- foundInPass = true;
- fdodscReceived = checkAndGetReceivedFlag (fdodscReceived);
- parseFDODSC (netSqldta);
- peekCP = peekCodePoint();
- }
+ netAgent_.setSvrcod(svrcod);
- if (peekCP == CodePoint.FDODTA) {
- foundInPass = true;
- fdodtaReceived = checkAndGetReceivedFlag (fdodtaReceived);
- netSqlca = parseFDODTA (netSqldta);
- peekCP = peekCodePoint();
- }
+ return pkgsnlst;
+ }
+
+ //--------------------- parse DDM Reply Data--------------------------------------
+
+
+ // SQL Data Reply Data consists of output data from the relational database (RDB)
+ // processing of an SQL statement. It also includes a description of the data.
+ //
+ // Returned from Server:
+ // FDODSC - required
+ // FDODTA - required
+ protected NetSqlca parseSQLDTARD(NetSqldta netSqldta) throws DisconnectException {
+ boolean fdodscReceived = false;
+ boolean fdodtaReceived = false;
+
+ parseLengthAndMatchCodePoint(CodePoint.SQLDTARD);
+ pushLengthOnCollectionStack();
+
+ NetSqlca netSqlca = null;
+ int peekCP = peekCodePoint();
+ while (peekCP != Reply.END_OF_COLLECTION) {
+
+ boolean foundInPass = false;
+
+ if (peekCP == CodePoint.FDODSC) {
+ foundInPass = true;
+ fdodscReceived = checkAndGetReceivedFlag(fdodscReceived);
+ parseFDODSC(netSqldta);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.FDODTA) {
+ foundInPass = true;
+ fdodtaReceived = checkAndGetReceivedFlag(fdodtaReceived);
+ netSqlca = parseFDODTA(netSqldta);
+ peekCP = peekCodePoint();
+ }
+
+ if (!foundInPass) {
+ doPrmnsprmSemantics(peekCP);
+ }
+
+ }
+ popCollectionStack();
+ checkRequiredObjects(fdodscReceived, fdodtaReceived);
+ netSqldta.calculateColumnOffsetsForRow();
+ return netSqlca;
+ }
+
+ protected void parseQRYDSC(NetCursor cursor) throws DisconnectException {
+ parseLengthAndMatchCodePoint(CodePoint.QRYDSC);
+ parseSQLDTARDarray(cursor, false); // false means don't just skip the bytes
+ }
+
+ private void parseFDODSC(NetCursor cursor) throws DisconnectException {
+ parseLengthAndMatchCodePoint(CodePoint.FDODSC);
+ parseSQLDTARDarray(cursor, false); // false means don't just skip the bytes
+ }
+
+ private void parseSQLDTARDarray(NetCursor cursor, boolean skipBytes) throws DisconnectException {
+ if (skipBytes) {
+ skipBytes();
+ }
+ int previousTripletType = FdocaConstants.SQLDTARD_TRIPLET_TYPE_START;
+ int previousTripletId = FdocaConstants.SQLDTARD_TRIPLET_ID_START;
+ int mddProtocolType = 0;
+ int columnCount = 0;
+ netAgent_.targetTypdef_.clearMddOverrides();
+
+ int ddmLength = getDdmLength();
+ ensureBLayerDataInBuffer(ddmLength);
+
+ while (ddmLength > 0) {
+
+ int tripletLength = readFastUnsignedByte();
+ int tripletType = readFastUnsignedByte();
+ int tripletId = readFastUnsignedByte();
+
+ switch (tripletType) {
+
+ case FdocaConstants.MDD_TRIPLET_TYPE:
+ if ((tripletLength != FdocaConstants.MDD_TRIPLET_SIZE) ||
+ (tripletId != FdocaConstants.NULL_LID)) {
+ descriptorErrorDetected();
+ }
+ checkPreviousSQLDTARDtriplet(previousTripletType,
+ FdocaConstants.SQLDTARD_TRIPLET_TYPE_MDD,
+ previousTripletId,
+ FdocaConstants.SQLDTARD_TRIPLET_ID_0);
+ previousTripletType = FdocaConstants.SQLDTARD_TRIPLET_TYPE_MDD;
+ previousTripletId = FdocaConstants.SQLDTARD_TRIPLET_ID_0;
+
+ // read in remaining MDD bytes
+ int mddClass = readFastUnsignedByte();
+ int mddType = readFastUnsignedByte();
+ int mddRefType = readFastUnsignedByte();
+ mddProtocolType = readFastUnsignedByte();
+ break;
+
+ case FdocaConstants.NGDA_TRIPLET_TYPE: // rename to NGDA_TRIPLET_CODEPOINT
+ if (tripletId != FdocaConstants.SQLDTAGRP_LID) {
+ descriptorErrorDetected();
+ }
+ checkPreviousSQLDTARDtriplet(previousTripletType,
+ FdocaConstants.SQLDTARD_TRIPLET_TYPE_GDA,
+ previousTripletId,
+ FdocaConstants.SQLDTARD_TRIPLET_ID_D0);
+ previousTripletType = FdocaConstants.SQLDTARD_TRIPLET_TYPE_GDA;
+ previousTripletId = FdocaConstants.SQLDTARD_TRIPLET_ID_0;
+
+ // add a quick check to see if the table is altered (columns are added or deleted)
+ // before reusing the cached cursor. note: this check does not catch the case
+ // where the number of columns stay the same, but the column type or length changes,
+ // i.e. from integer to char.
+ int columns = peekTotalColumnCount(tripletLength);
+ // peek ahead to get the total number of columns.
+ cursor.initializeColumnInfoArrays(netAgent_.targetTypdef_, columns, netAgent_.targetSqlam_);
[... 2333 lines stripped ...]