Added:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageReply.java
URL:
http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageReply.java?rev=165178&view=auto
==============================================================================
---
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageReply.java
(added)
+++
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageReply.java
Thu Apr 28 12:05:42 2005
@@ -0,0 +1,215 @@
+/*
+
+ Derby - Class org.apache.derby.client.net.NetPackageReply
+
+ 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.DisconnectException;
+
+public class NetPackageReply extends NetConnectionReply
+{
+ NetPackageReply (NetAgent netAgent, int bufferSize)
+ {
+ super (netAgent, bufferSize);
+ }
+
+
+ NetSqlca parseSqlErrorCondition () throws DisconnectException
+ {
+ parseSQLERRRM();
+ parseTypdefsOrMgrlvlovrs ();
+ NetSqlca netSqlca = parseSQLCARD (null);
+ return netSqlca;
+ }
+
+
+ // Also called by NetStatementReply
+ void parseDTAMCHRM () throws DisconnectException
+ {
+ boolean svrcodReceived = false;
+ int svrcod = CodePoint.SVRCOD_INFO;
+ boolean rdbnamReceived = false;
+ String rdbnam = null;
+
+ parseLengthAndMatchCodePoint (CodePoint.DTAMCHRM);
+ 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 (!foundInPass)
+ doPrmnsprmSemantics (peekCP);
+
+ }
+ popCollectionStack();
+ checkRequiredObjects (svrcodReceived, rdbnamReceived);
+
+ netAgent_.setSvrcod (svrcod);
+ doDtamchrmSemantics();
+ }
+
+ // RDB Update Reply Message indicates that a DDM command resulted
+ // in an update at the target relational database. If a command
+ // generated multiple reply messages including an RDBUPDRM, then
+ // the RDBUPDRM must be the first reply message for the command.
+ // For each target server, the RDBUPDRM must be returned the first
+ // time an update is made to the target RDB within a unit of work.
+ // The target server may optionally return the RDBUPDRM after subsequent
+ // updates within the UOW. If multiple target RDBs are involved with
+ // the current UOW and updates are made with any of them, then the RDBUPDRM
+ // must be returned in response to the first update at each of them.
+ protected void parseRDBUPDRM () throws DisconnectException
+ {
+ boolean svrcodReceived = false;
+ int svrcod = CodePoint.SVRCOD_INFO;
+ boolean rdbnamReceived = false;
+ String rdbnam = null;
+
+ parseLengthAndMatchCodePoint (CodePoint.RDBUPDRM);
+ pushLengthOnCollectionStack();
+
+ // in XA Global transaction we need to know if we have a read-only
+ // transaction, if we get a RDBUPDRM this is NOT a read-only transaction
+ // currently only XAConnections care about read-only transactions, if
+ // non-XA wants this information they will need to initialize the flag
+ // at start of UOW
+ netAgent_.netConnection_.setReadOnlyTransactionFlag( false );
+
+ 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.RDBNAM) {
+ foundInPass = true;
+ rdbnamReceived = checkAndGetReceivedFlag (rdbnamReceived);
+ rdbnam = parseRDBNAM (true);
+ peekCP = peekCodePoint();
+ }
+
+ if (!foundInPass)
+ doPrmnsprmSemantics (peekCP);
+
+ }
+ popCollectionStack();
+ checkRequiredObjects (svrcodReceived, rdbnamReceived);
+
+ // call an event to indicate the server has been updated
+ netAgent_.setSvrcod (svrcod);
+
+ }
+
+ // SQL Error Condition Reply Message indicates that an SQL error
+ // has occurred. It may be sent even though no reply message
+ // precedes the SQLCARD object that is the normal
+ // response to a command when an exception occurs.
+ // The SQLERRM is also used when a BNDSQLSTT command is terminated
+ // by an INTRRDBRQS command.
+ // This reply message must precede an SQLCARD object.
+ // The SQLSTATE is returned in the SQLCARD.
+ //
+ // Returned from Server:
+ // SVRCOD - required (8 - ERROR)
+ // RDBNAM - optional
+ //
+ // Also called by NetResultSetReply and NetStatementReply
+ void parseSQLERRRM () throws DisconnectException
+ {
+ boolean svrcodReceived = false;
+ int svrcod = CodePoint.SVRCOD_INFO;
+ boolean rdbnamReceived = false;
+ String rdbnam = null;
+
+ parseLengthAndMatchCodePoint (CodePoint.SQLERRRM);
+ 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 (!foundInPass)
+ doPrmnsprmSemantics (peekCP);
+
+ }
+ popCollectionStack();
+ checkRequiredObjects (svrcodReceived);
+
+ // move into a method
+ netAgent_.setSvrcod (svrcod);
+ }
+
+ //--------------------- parse DDM Reply
Data--------------------------------------
+
+ //------------------------parse DDM Scalars-----------------------------
+
+ // RDB Package Name and Consistency token Scalar Object specifies the
+ // fully qualified name of a relational database package and its
+ // consistency token.
+ protected Object parsePKGNAMCT (boolean skip) throws DisconnectException
+ {
+ parseLengthAndMatchCodePoint (CodePoint.PKGNAMCT);
+ if (skip) {
+ skipBytes();
+ return null;
+ }
+ agent_.accumulateChainBreakingReadExceptionAndThrow (new
DisconnectException (
+ agent_,
+ "parsePKGNAMCT not yet implemented"));
+ return null; // to make compiler happy
+ }
+}
Propchange:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageReply.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java
URL:
http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java?rev=165178&view=auto
==============================================================================
---
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java
(added)
+++
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java
Thu Apr 28 12:05:42 2005
@@ -0,0 +1,310 @@
+/*
+
+ Derby - Class org.apache.derby.client.net.NetPackageRequest
+
+ 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.Configuration;
+import org.apache.derby.client.am.Section;
+import org.apache.derby.client.am.SqlException;
+
+
+public class NetPackageRequest extends NetConnectionRequest
+{
+ static final String COLLECTIONNAME = "NULLID";
+
+ NetPackageRequest (NetAgent netAgent, CcsidManager ccsidManager, int
bufferSize)
+ {
+ super (netAgent, ccsidManager, bufferSize);
+ }
+
+ // RDB Package Name, Consistency Token
+ // Scalar Object specifies the fully qualified name of a relational
+ // database package and its consistency token.
+ //
+ // To accomodate larger lengths, the Scalar Data Length
+ // (SCLDTALEN) Field is used to specify the length of the instance
+ // variable which follows.
+ static final String collectionName = "NULLID";
+ void buildCommonPKGNAMinfo (Section section) throws SqlException
+ {
+ String collectionToFlow = COLLECTIONNAME;
+ // the scalar data length field may or may not be required. it depends
+ // on the level of support and length of the data.
+ // check the lengths of the RDBNAM, RDBCOLID, and PKGID.
+ // Determine if the lengths require an SCLDTALEN object.
+ // Note: if an SQLDTALEN is required for ONE of them,
+ // it is needed for ALL of them. This is why this check is
+ // up front.
+ // the SQLAM level dictates the maximum size for
+ // RDB Collection Identifier (RDBCOLID)
+ // Relational Database Name (RDBNAM)
+ // RDB Package Identifier (PKGID)
+ int maxIdentifierLength = NetConfiguration.PKG_IDENTIFIER_MAX_LEN;
+
+ boolean scldtalenRequired = false;
+ scldtalenRequired = checkPKGNAMlengths
(netAgent_.netConnection_.databaseName_,
+ maxIdentifierLength,
+
NetConfiguration.PKG_IDENTIFIER_FIXED_LEN);
+
+ if (!scldtalenRequired)
+ scldtalenRequired = checkPKGNAMlengths (collectionToFlow,
+ maxIdentifierLength,
+
NetConfiguration.PKG_IDENTIFIER_FIXED_LEN);
+
+ if (!scldtalenRequired)
+ scldtalenRequired = checkPKGNAMlengths (section.getPackageName(),
+ maxIdentifierLength,
+
NetConfiguration.PKG_IDENTIFIER_FIXED_LEN);
+
+ // the format is different depending on if an SCLDTALEN is required.
+ if (!scldtalenRequired) {
+ writeScalarPaddedString (netAgent_.netConnection_.databaseName_,
+ NetConfiguration.PKG_IDENTIFIER_FIXED_LEN);
+ writeScalarPaddedString (collectionToFlow,
+ NetConfiguration.PKG_IDENTIFIER_FIXED_LEN);
+ writeScalarPaddedString (section.getPackageName(),
+ NetConfiguration.PKG_IDENTIFIER_FIXED_LEN);
+ }
+ else {
+ buildSCLDTA (netAgent_.netConnection_.databaseName_,
NetConfiguration.PKG_IDENTIFIER_FIXED_LEN);
+ buildSCLDTA (collectionToFlow,
NetConfiguration.PKG_IDENTIFIER_FIXED_LEN);
+ buildSCLDTA (section.getPackageName(),
NetConfiguration.PKG_IDENTIFIER_FIXED_LEN);
+ }
+ }
+
+ private void buildSCLDTA (String identifier, int minimumLength) throws
SqlException
+ {
+ if (identifier.length() <= minimumLength) {
+ write2Bytes (minimumLength);
+ writeScalarPaddedString (identifier, minimumLength);
+ }
+ else {
+ write2Bytes (identifier.length());
+ writeScalarPaddedString (identifier, identifier.length());
+ }
+ }
+
+
+ // this specifies the fully qualified package name,
+ // consistency token, and section number within the package being used
+ // to execute the SQL. If the connection supports reusing the previous
+ // package information and this information is the same except for the
section
+ // number then only the section number needs to be sent to the server.
+ void buildPKGNAMCSN (Section section) throws SqlException
+ {
+ if (!canCommandUseDefaultPKGNAMCSN ()) {
+ markLengthBytes (CodePoint.PKGNAMCSN);
+ // If PKGNAMCBytes is already available, copy the bytes to the request
buffer directly.
+ if (section.getPKGNAMCBytes() != null)
+ writeStoredPKGNAMCBytes (section);
+ else {
+ // Mark the beginning of PKGNAMCSN bytes.
+ markForCachingPKGNAMCSN ();
+ buildCommonPKGNAMinfo (section);
+ writeScalarPaddedBytes (Configuration.dncPackageConsistencyToken,
+ NetConfiguration.PKGCNSTKN_FIXED_LEN,
+ NetConfiguration.NON_CHAR_DDM_DATA_PAD_BYTE);
+ // store the PKGNAMCbytes
+ storePKGNAMCBytes (section);
+ }
+ write2Bytes (section.getSectionNumber());
+ updateLengthBytes();
+ }
+ else
+ writeScalar2Bytes (CodePoint.PKGSN, section.getSectionNumber());
+ }
+
+ private void storePKGNAMCBytes (Section section)
+ {
+ // Get the locaton where we started writing PKGNAMCSN
+ int startPos = popMarkForCachingPKGNAMCSN ();
+ int copyLength = offset_ - startPos;
+ byte[] b = new byte[copyLength];
+ System.arraycopy (bytes_,
+ startPos,
+ b,
+ 0,
+ copyLength);
+ section.setPKGNAMCBytes(b);
+ }
+
+ private void writeStoredPKGNAMCBytes (Section section)
+ {
+ byte[] b = section.getPKGNAMCBytes();
+
+ // Mare sure request buffer has enough space to write this byte array.
+ ensureLength (offset_ + b.length);
+
+ System.arraycopy (b,
+ 0,
+ bytes_,
+ offset_,
+ b.length);
+
+ offset_ += b.length;
+ }
+
+ private boolean canCommandUseDefaultPKGNAMCSN ()
+ {
+ return false;
+ }
+
+
+ // throws an exception if lengths exceed the maximum.
+ // returns a boolean indicating if SLCDTALEN is required.
+ private boolean checkPKGNAMlengths (String identifier,
+ int maxIdentifierLength,
+ int lengthRequiringScldta) throws
SqlException
+ {
+ int length = identifier.length();
+ if (length > maxIdentifierLength)
+ throw new SqlException (netAgent_.logWriter_, "" + identifier + "
exceeds maximum identifier length of ' " +
+ maxIdentifierLength + "'");
+
+ return (length > lengthRequiringScldta);
+ }
+
+ private byte[] getBytes (String string, String encoding) throws SqlException
+ {
+ try {
+ return string.getBytes (encoding);
+ }
+ catch (java.lang.Exception e) {
+ throw new SqlException (netAgent_.logWriter_, e, "error on getBytes");
+ }
+ }
+
+ private void buildNOCMorNOCS (String string) throws SqlException
+ {
+ if (string == null) {
+ write2Bytes (0xffff);
+ }
+ else {
+ byte[] sqlBytes = null;
+
+ if (netAgent_.typdef_.isCcsidMbcSet()) {
+ sqlBytes = getBytes (string, netAgent_.typdef_.getCcsidMbcEncoding());
+ write1Byte (0x00);
+ write4Bytes (sqlBytes.length);
+ writeBytes (sqlBytes, sqlBytes.length);
+ write1Byte (0xff);
+ }
+ else {
+ sqlBytes = getBytes (string, netAgent_.typdef_.getCcsidSbcEncoding());
+ write1Byte (0xff);
+ write1Byte (0x00);
+ write4Bytes (sqlBytes.length);
+ writeBytes (sqlBytes, sqlBytes.length);
+ }
+ }
+ }
+
+ // SQLSTTGRP : FDOCA EARLY GROUP
+ // SQL Statement Group Description
+ //
+ // FORMAT FOR SQLAM <= 6
+ // SQLSTATEMENT_m; PROTOCOL TYPE LVCM; ENVLID 0x40; Length Override 32767
+ // SQLSTATEMENT_s; PROTOCOL TYPE LVCS; ENVLID 0x34; Length Override 32767
+ //
+ // FORMAT FOR SQLAM >= 7
+ // SQLSTATEMENT_m; PROTOCOL TYPE NOCM; ENVLID 0xCF; Length Override 4
+ // SQLSTATEMENT_s; PROTOCOL TYPE NOCS; ENVLID 0xCB; Length Override 4
+ private void buildSQLSTTGRP (String string) throws SqlException
+ {
+ buildNOCMorNOCS (string);
+ return;
+ }
+
+ // SQLSTT : FDOCA EARLY ROW
+ // SQL Statement Row Description
+ //
+ // FORMAT FOR ALL SQLAM LEVELS
+ // SQLSTTGRP; GROUP LID 0x5C; ELEMENT TAKEN 0(all); REP FACTOR 1
+ private void buildSQLSTT (String string) throws SqlException
+ {
+ buildSQLSTTGRP (string);
+ }
+
+ protected void buildSQLSTTcommandData (String sql) throws SqlException
+ {
+ createEncryptedCommandData ();
+ int loc = offset_;
+ markLengthBytes (CodePoint.SQLSTT);
+ buildSQLSTT (sql);
+ updateLengthBytes();
+ if (netAgent_.netConnection_.getSecurityMechanism() ==
+ NetConfiguration.SECMEC_EUSRIDDTA ||
+ netAgent_.netConnection_.getSecurityMechanism() ==
+ NetConfiguration.SECMEC_EUSRPWDDTA)
+ encryptDataStream(loc);
+
+ }
+
+
+
+ protected void buildSQLATTRcommandData (String sql) throws SqlException
+ {
+ createEncryptedCommandData ();
+ int loc = offset_;
+ markLengthBytes (CodePoint.SQLATTR);
+ buildSQLSTT (sql);
+ updateLengthBytes();
+ if (netAgent_.netConnection_.getSecurityMechanism() ==
+ NetConfiguration.SECMEC_EUSRIDDTA ||
+ netAgent_.netConnection_.getSecurityMechanism() ==
+ NetConfiguration.SECMEC_EUSRPWDDTA)
+ encryptDataStream (loc);
+
+ }
+
+
+ public void encryptDataStream(int lengthLocation) throws SqlException
+ {
+ byte[] clearedBytes = new byte[offset_ - lengthLocation];
+ byte[] encryptedBytes;
+ for (int i = lengthLocation; i < offset_; i++)
+ clearedBytes[i - lengthLocation] = bytes_[i];
+
+ encryptedBytes = netAgent_.netConnection_.getEncryptionManager().
+ encryptData(
+ clearedBytes,
+ NetConfiguration.SECMEC_EUSRIDPWD,
+ netAgent_.netConnection_.getTargetPublicKey(),
+ netAgent_.netConnection_.getTargetPublicKey());
+
+ int length = encryptedBytes.length;
+
+ if(bytes_.length >= lengthLocation + length)
+ System.arraycopy(encryptedBytes, 0, bytes_, lengthLocation, length);
+ else {
+ byte[] largeByte = new byte[lengthLocation + length];
+ System.arraycopy(bytes_,0,largeByte,0,lengthLocation);
+ System.arraycopy(encryptedBytes, 0, largeByte, lengthLocation, length);
+ bytes_ = largeByte;
+ }
+
+ offset_ += length - clearedBytes.length;
+
+ //we need to update the length in DSS header here.
+
+ bytes_[lengthLocation - 6] = (byte) ( (length >>> 8) & 0xff);
+ bytes_[lengthLocation - 5] = (byte) (length & 0xff);
+ }
+
+}
Propchange:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPackageRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPreparedStatement.java
URL:
http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPreparedStatement.java?rev=165178&view=auto
==============================================================================
---
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPreparedStatement.java
(added)
+++
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPreparedStatement.java
Thu Apr 28 12:05:42 2005
@@ -0,0 +1,165 @@
+/*
+
+ Derby - Class org.apache.derby.client.net.NetPreparedStatement
+
+ 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.Section;
+import org.apache.derby.client.am.ColumnMetaData;
+import org.apache.derby.client.am.PreparedStatement;
+import org.apache.derby.client.am.SqlException;
+
+
+public class NetPreparedStatement extends NetStatement
+ implements org.apache.derby.client.am.MaterialPreparedStatement
+{
+
+ // Alias for (NetPreparedStatement) super.statement.
+ /*final*/ org.apache.derby.client.am.PreparedStatement preparedStatement_;
+
+
+ // Relay constructor for NetCallableStatement.
+ NetPreparedStatement (org.apache.derby.client.am.PreparedStatement statement,
+ NetAgent netAgent,
+ NetConnection netConnection)
+ {
+ super (statement, netAgent, netConnection);
+ initNetPreparedStatement (statement);
+ }
+
+ void resetNetPreparedStatement (org.apache.derby.client.am.PreparedStatement
statement,
+ NetAgent netAgent,
+ NetConnection netConnection)
+ {
+ super.resetNetStatement(statement, netAgent, netConnection);
+ initNetPreparedStatement(statement);
+ }
+
+ private void initNetPreparedStatement
(org.apache.derby.client.am.PreparedStatement statement)
+ {
+ preparedStatement_ = statement;
+ preparedStatement_.materialPreparedStatement_ = this;
+ }
+
+ // Called by abstract Connection.prepareStatment().newPreparedStatement()
for jdbc 2 prepared statements
+ // with scroll attributes.
+ NetPreparedStatement (NetAgent netAgent, NetConnection netConnection, String
sql, int type, int concurrency, int holdability, int autoGeneratedKeys,
String[] columnNames) throws SqlException
+ {
+ this (new PreparedStatement (netAgent, netConnection, sql, type,
concurrency, holdability, autoGeneratedKeys, columnNames),
+ netAgent,
+ netConnection);
+ }
+
+ void resetNetPreparedStatement (NetAgent netAgent, NetConnection
netConnection, String sql, int type, int concurrency, int holdability, int
autoGeneratedKeys, String[] columnNames) throws SqlException
+ {
+ preparedStatement_.resetPreparedStatement(netAgent, netConnection, sql,
type, concurrency, holdability, autoGeneratedKeys, columnNames);
+ resetNetPreparedStatement(preparedStatement_, netAgent, netConnection);
+ }
+
+ // For JDBC 3.0 positioned updates.
+ NetPreparedStatement (NetAgent netAgent,
+ NetConnection netConnection,
+ String sql,
+ Section section) throws SqlException
+ {
+ this (new PreparedStatement (netAgent, netConnection, sql, section),
+ netAgent,
+ netConnection);
+ }
+
+ void resetNetPreparedStatement (NetAgent netAgent,
+ NetConnection netConnection,
+ String sql,
+ Section section) throws SqlException
+ {
+ preparedStatement_.resetPreparedStatement (netAgent, netConnection, sql,
section);
+ resetNetPreparedStatement (preparedStatement_, netAgent, netConnection);
+ }
+
+ void resetNetPreparedStatement (NetAgent netAgent,
+ NetConnection netConnection,
+ String sql,
+ Section section,
+ ColumnMetaData parameterMetaData,
+ ColumnMetaData resultSetMetaData) throws
SqlException
+ {
+
preparedStatement_.resetPreparedStatement(netAgent,netConnection,sql,section,parameterMetaData,resultSetMetaData);
+ this.resetNetPreparedStatement(preparedStatement_, netAgent,
netConnection);
+ }
+
+ protected void finalize () throws java.lang.Throwable
+ {
+ super.finalize();
+ }
+
+ public void writeExecute_ (Section section,
+ ColumnMetaData parameterMetaData,
+ Object[] inputs,
+ int numInputColumns,
+ boolean outputExpected,
+ // This is a hint to the material layer that more
write commands will follow.
+ // It is ignored by the driver in all cases except
when blob data is written,
+ // in which case this boolean is used to optimize
the implementation.
+ // Otherwise we wouldn't be able to chain after
blob data is sent.
+ // If we could always chain a no-op DDM after
every execute that writes blobs
+ // then we could just always set the chaining flag
to on for blob send data
+ boolean chainedWritesFollowingSetLob
+ ) throws SqlException
+ {
+ netAgent_.statementRequest_.writeExecute (
+ this,
+ section,
+ parameterMetaData,
+ inputs,
+ numInputColumns,
+ outputExpected,
+ chainedWritesFollowingSetLob);
+ }
+
+
+ public void readExecute_ () throws SqlException
+ { netAgent_.statementReply_.readExecute (preparedStatement_); }
+
+ public void writeOpenQuery_ (Section section,
+ int fetchSize,
+ int resultSetType,
+ int numInputColumns,
+ ColumnMetaData parameterMetaData,
+ Object[] inputs) throws SqlException
+ {
+ netAgent_.statementRequest_.writeOpenQuery (
+ this,
+ section,
+ fetchSize,
+ resultSetType,
+ numInputColumns,
+ parameterMetaData,
+ inputs);
+ }
+ // super.readOpenQuery()
+
+ public void writeDescribeInput_ (Section section) throws SqlException
+ { netAgent_.statementRequest_.writeDescribeInput (this, section); }
+ public void readDescribeInput_ () throws SqlException
+ { netAgent_.statementReply_.readDescribeInput (preparedStatement_); }
+
+ public void writeDescribeOutput_ (Section section) throws SqlException
+ { netAgent_.statementRequest_.writeDescribeOutput (this, section); }
+ public void readDescribeOutput_ () throws SqlException
+ { netAgent_.statementReply_.readDescribeOutput (preparedStatement_); }
+}
Propchange:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetPreparedStatement.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet.java
URL:
http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet.java?rev=165178&view=auto
==============================================================================
---
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet.java
(added)
+++
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet.java
Thu Apr 28 12:05:42 2005
@@ -0,0 +1,221 @@
+/*
+
+ Derby - Class org.apache.derby.client.net.NetResultSet
+
+ 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.SqlException;
+import org.apache.derby.client.am.DisconnectException;
+import org.apache.derby.client.am.Cursor;
+import org.apache.derby.client.am.Section;
+
+
+public class NetResultSet extends org.apache.derby.client.am.ResultSet
+{
+ // Alias for (NetConnection) super.statement.connection
+ private final NetConnection netConnection_;
+
+ // Alias for (NetStatement) super.statement
+ private final NetStatement netStatement_;
+
+ // Alias for (NetCursor) super.cursor
+ final NetCursor netCursor_;
+
+ // Alias for (NetAgent) super.agent
+ final private NetAgent netAgent_;
+
+
//-----------------------------state------------------------------------------
+
+ // This is used to avoid sending multiple outovr over subsequent next()'s
+ public boolean firstOutovrBuilt_ = false;
+
+
//---------------------constructors/finalizer---------------------------------
+
+ // parseOpnqrym() is called right after this constructor is called.
+
+ NetResultSet (NetAgent netAgent,
+ NetStatement netStatement,
+ Cursor cursor,
+ //int qryprctyp, //protocolType, CodePoint.FIXROWPRC |
CodePoint.LMTBLKPRC
+ int sqlcsrhld, // holdOption, 0xF0 for false (default) | 0xF1
for true.
+ int qryattscr, // scrollOption, 0xF0 for false (default) |
0xF1 for true.
+ int qryattsns, // sensitivity, CodePoint.QRYUNK |
CodePoint.QRYINS
+ int qryattset, // rowsetCursor, 0xF0 for false (default) |
0xF1 for true.
+ long qryinsid, // instanceIdentifier, 0 (if not returned,
check default) or number
+ int actualResultSetType,
+ int actualResultSetConcurrency,
+ int actualResultSetHoldability
+ ) //throws DisconnectException
+ {
+ super (netAgent,
+ netStatement.statement_,
+ //new NetCursor (netAgent, qryprctyp),
+ cursor,
+ // call the constructor with the real resultSetType and
resultSetConcurrency
+ // returned from the server
+ actualResultSetType,
+ actualResultSetConcurrency,
+ actualResultSetHoldability);
+
+ netAgent_ = netAgent;
+
+ // Set up cheat-links
+ netCursor_ = (NetCursor) cursor_;
+ netStatement_ = netStatement;
+ netConnection_ = netStatement.netConnection_;
+
+ netCursor_.netResultSet_ = this;
+
+ cursorHold_ = (sqlcsrhld != 0xf0);
+ if (qryattscr == 0xF1) scrollable_ = true;
+
+ switch (qryattsns) {
+ case CodePoint.QRYUNK:
+ sensitivity_ = sensitivity_unknown__;
+ break;
+ case CodePoint.QRYINS:
+ sensitivity_ = sensitivity_insensitive__;
+ break;
+ default: // shouldn't happen
+ break;
+ }
+
+ if (qryattset == 0xF1) isRowsetCursor_ = true;
+
+ queryInstanceIdentifier_ = qryinsid;
+ nestingLevel_ = (int)((queryInstanceIdentifier_ >>> 48) & 0xFFFF);
+ }
+
+
+ //-------------------------------flow
methods---------------------------------
+
+ // Go through the QRYDTA's received, and calculate the column offsets for
each row.
+ protected void parseRowset_ () throws SqlException
+ {
+ int row = 0;
+ // Parse all the rows received in the rowset
+ // The index we are passing will keep track of which row in the rowset we
are parsing
+ // so we can reuse the columnDataPosition/Length/IsNull arrays.
+ while (netCursor_.calculateColumnOffsetsForRow_(row)) {
+ rowsReceivedInCurrentRowset_++;
+ row++;
+ }
+
+ // if rowset is not complete and an endqryrm was received, will skip the
while loop
+ // and go to the checkAndThrow method. otherwise flow an cntqry to try to
complete
+ // the rowset.
+ // -- there is no need to complete the rowset for rowset cursors.
fetching stops when
+ // the end of data is returned or when an error occurs. all
successfully fetched rows
+ // are returned to the user. the specific error is not returned until
the next fetch.
+ while (rowsReceivedInCurrentRowset_ != fetchSize_ &&
+ !netCursor_.allRowsReceivedFromServer_ && !isRowsetCursor_ &&
+ sensitivity_ != sensitivity_sensitive_dynamic__) {
+ flowFetchToCompleteRowset ();
+ while (netCursor_.calculateColumnOffsetsForRow_(row)) {
+ rowsReceivedInCurrentRowset_++;
+ row++;
+ }
+ }
+ checkAndThrowReceivedQueryTerminatingException();
+ }
+
+ public void setFetchSize_ (int rows) { fetchSize_ = (rows == 0) ? 64 : rows;
}
+
+ //-----------------------------helper
methods---------------------------------
+
+ void flowFetchToCompleteRowset () throws DisconnectException
+ {
+ try {
+ agent_.beginWriteChain (statement_);
+
+ writeScrollableFetch_ ((generatedSection_ == null) ? statement_.section_
: generatedSection_,
+ fetchSize_ - rowsReceivedInCurrentRowset_,
+ scrollOrientation_relative__,
+ 1,
+ false); // false means do not disard pending
+ // partial row and pending query blocks
+
+ agent_.flow (statement_);
+ readScrollableFetch_ ();
+ agent_.endReadChain ();
+ }
+ catch (SqlException e) {
+ throw new DisconnectException (agent_, e);
+ }
+ }
+
+ void queryDataWasReturnedOnOpen() throws DisconnectException
+ {
+ }
+
+ // ------------------------------- abstract box car methods
--------------------------------------
+ public void writeFetch_ (Section section) throws SqlException
+ {
+ if (resultSetType_ == java.sql.ResultSet.TYPE_FORWARD_ONLY && fetchSize_
!= 0 &&
+ rowsYetToBeReceivedForRowset_ > 0)
+ netAgent_.resultSetRequest_.writeFetch (this,
+ section,
+ rowsYetToBeReceivedForRowset_);
+ else
+ netAgent_.resultSetRequest_.writeFetch (this,
+ section,
+ fetchSize_);
+ }
+
+ public void readFetch_ () throws SqlException
+ { netAgent_.resultSetReply_.readFetch (this); }
+
+ public void writeScrollableFetch_ (Section section,
+ int fetchSize,
+ int orientation,
+ long rowToFetch,
+ boolean resetQueryBlocks) throws
SqlException
+ {
+ netAgent_.resultSetRequest_.writeScrollableFetch (
+ this,
+ section,
+ fetchSize,
+ orientation,
+ rowToFetch,
+ resetQueryBlocks);
+ }
+
+ // think about splitting out the position cursor stuff from the fetch stuff
+ // use commented out abstract position cursor methods above
+ public void readScrollableFetch_ () throws SqlException
+ { netAgent_.resultSetReply_.readScrollableFetch (this); }
+
+ public void writePositioningFetch_ (Section section,
+ int orientation,
+ long rowToFetch) throws SqlException
+ {
+ netAgent_.resultSetRequest_.writePositioningFetch (
+ this,
+ section,
+ orientation,
+ rowToFetch);
+ }
+
+ public void readPositioningFetch_ () throws SqlException
+ { netAgent_.resultSetReply_.readPositioningFetch (this); }
+
+ public void writeCursorClose_ (Section section) throws SqlException
+ { netAgent_.resultSetRequest_.writeCursorClose (this, section); }
+ public void readCursorClose_ () throws SqlException
+ { netAgent_.resultSetReply_.readCursorClose (this); }
+}
Propchange:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSet.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java
URL:
http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java?rev=165178&view=auto
==============================================================================
---
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java
(added)
+++
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java
Thu Apr 28 12:05:42 2005
@@ -0,0 +1,345 @@
+/*
+
+ Derby - Class org.apache.derby.client.net.NetResultSetReply
+
+ 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.SqlState;
+
+import org.apache.derby.client.am.SqlException;
+import org.apache.derby.client.am.DisconnectException;
+
+import org.apache.derby.client.am.ResultSet;
+import org.apache.derby.client.am.ResultSetCallbackInterface;
+
+public class NetResultSetReply extends NetStatementReply implements
ResultSetReplyInterface
+{
+ public NetResultSetReply (NetAgent netAgent, int bufferSize)
+ {
+ super (netAgent, bufferSize);
+ }
+
+ //----------------------------- entry points
---------------------------------
+
+ public void readFetch (ResultSetCallbackInterface resultSet) throws
DisconnectException
+ {
+ startSameIdChainParse();
+ parseCNTQRYreply (resultSet, true); // true means we expect row data
+ endOfSameIdChainData();
+ }
+
+ public void readPositioningFetch (ResultSetCallbackInterface resultSet)
throws DisconnectException
+ {
+ startSameIdChainParse();
+ parseCNTQRYreply (resultSet, false); // false means return data is not
expected
+ endOfSameIdChainData();
+ }
+
+ public void readScrollableFetch (ResultSetCallbackInterface resultSet)
throws DisconnectException
+ {
+ startSameIdChainParse();
+ parseCNTQRYreply (resultSet, true); // true means return data is expected
+ endOfSameIdChainData();
+ }
+
+ public void readCursorClose (ResultSetCallbackInterface resultSet) throws
DisconnectException
+ {
+ startSameIdChainParse();
+ parseCLSQRYreply (resultSet);
+ 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.
+
+ // Parse the reply for the Close Query Command.
+ // This method handles the parsing of all command replies and reply data
+ // for the clsqry command.
+ private void parseCLSQRYreply (ResultSetCallbackInterface resultSet) throws
DisconnectException
+ {
+ int peekCP = parseTypdefsOrMgrlvlovrs ();
+
+ if (peekCP == CodePoint.SQLCARD) {
+ NetSqlca netSqlca = parseSQLCARD (null); //@f48553sxg - null means
rowsetSqlca_ is null
+ // Set the cursor state if null SQLCA or sqlcode is equal to 0.
+ resultSet.completeSqlca (netSqlca);
+ }
+ else
+ parseCloseError (resultSet);
+ }
+
+ // Parse the reply for the Continue Query Command.
+ // This method handles the parsing of all command replies and reply data for
the cntqry command.
+ // If doCopyQrydta==false, then there is no data, and we're only parsing out
the sqlca to get the row count.
+ private void parseCNTQRYreply (ResultSetCallbackInterface resultSetI,
+ boolean doCopyQrydta) throws
DisconnectException
+ {
+ boolean found = false;
+ int peekCP = peekCodePoint();
+ if (peekCP == CodePoint.RDBUPDRM) {
+ found = true;
+ parseRDBUPDRM();
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.QRYDTA) {
+ found = true;
+ if (!doCopyQrydta) {
+ parseLengthAndMatchCodePoint (CodePoint.QRYDTA);
+ //we don't need to copy QRYDTA since there is no data
+ if (longValueForDecryption_ != null)
+ longValueForDecryption_ = null;
+ if (longBufferForDecryption_ != null)
+ longBufferForDecryption_ = null;
+
+ int ddmLength = getDdmLength();
+ ensureBLayerDataInBuffer (ddmLength);
+ ((ResultSet)resultSetI).expandRowsetSqlca ();
+ NetSqlca sqlca = parseSQLCARDrow
(((ResultSet)resultSetI).rowsetSqlca_);
+ int daNullIndicator = readFastByte();
+ adjustLengths (getDdmLength());
+ // define event interface and use the event method
+ // only get the rowCount_ if sqlca is not null and rowCount_ is unknown
+ if (sqlca != null && sqlca.containsSqlcax())
+ ((ResultSet) resultSetI).setRowCountEvent
(sqlca.getRowCount(netAgent_.targetTypdef_));
+
+ peekCP = peekCodePoint();
+ if (peekCP == CodePoint.RDBUPDRM) {
+ parseRDBUPDRM();
+ peekCP = peekCodePoint();
+ }
+ return;
+ }
+ do {
+ parseQRYDTA ((NetResultSet) resultSetI);
+ peekCP = peekCodePoint();
+ } while (peekCP == CodePoint.QRYDTA);
+ }
+
+ if (peekCP == CodePoint.EXTDTA) {
+ found = true;
+ do {
+ copyEXTDTA ((NetCursor)((ResultSet) resultSetI).cursor_);
+ if (longBufferForDecryption_ != null ) {//encrypted EXTDTA
+ buffer_ = longBufferForDecryption_;
+ pos_ = longPosForDecryption_;
+ if (longBufferForDecryption_ != null && count_ >
longBufferForDecryption_.length)
+ count_ = longBufferForDecryption_.length;
+ }
+
+ peekCP = peekCodePoint();
+ } while (peekCP == CodePoint.EXTDTA);
+ }
+
+ if (peekCP == CodePoint.SQLCARD) {
+ found = true;
+ ((ResultSet)resultSetI).expandRowsetSqlca ();
+ NetSqlca netSqlca = parseSQLCARD (((ResultSet)resultSetI).rowsetSqlca_);
+ // for an atomic operation, the SQLCA contains the sqlcode for the first
(statement
+ // terminating)error, the last warning, or zero. all multi-row fetch
operatons are
+ // atomic. (the only operation that is not atomic is multi-row insert).
+ if (((ResultSet)resultSetI).sensitivity_ !=
ResultSet.sensitivity_sensitive_dynamic__) {
+ if (netSqlca != null && netSqlca.containsSqlcax() &&
netSqlca.getRowsetRowCount() == 0)
+ ((ResultSet) resultSetI).setRowCountEvent
(netSqlca.getRowCount(netAgent_.targetTypdef_));
+ }
+ resultSetI.completeSqlca (netSqlca);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.ENDQRYRM) {
+ found = true;
+ parseEndQuery (resultSetI);
+ peekCP = peekCodePoint();
+ }
+
+ if (peekCP == CodePoint.RDBUPDRM) {
+ found = true;
+ parseRDBUPDRM();
+ }
+
+ if (!found)
+ parseFetchError (resultSetI);
+
+ if (longBufferForDecryption_ != null) {
+ // Not a good idea to create a new buffer_
+ buffer_ = new byte[DEFAULT_BUFFER_SIZE];
+ longBufferForDecryption_ = null;
+ }
+ }
+
+ void parseCloseError (ResultSetCallbackInterface resultSetI) throws
DisconnectException
+ {
+ int peekCP = peekCodePoint();
+ switch (peekCP) {
+ case CodePoint.ABNUOWRM: {
+ NetSqlca sqlca = parseAbnormalEndUow
(resultSetI.getConnectionCallbackInterface());
+ resultSetI.completeSqlca (sqlca);
+ break;
+ }
+ case CodePoint.CMDCHKRM:
+ parseCMDCHKRM();
+ break;
+ case CodePoint.QRYNOPRM:
+ parseQRYNOPRM (resultSetI);
+ break;
+ case CodePoint.RDBNACRM:
+ parseRDBNACRM();
+ break;
+ default:
+ parseCommonError (peekCP);
+ }
+ }
+
+ void parseFetchError (ResultSetCallbackInterface resultSetI) throws
DisconnectException
+ {
+ int peekCP = peekCodePoint();
+ switch (peekCP) {
+ case CodePoint.ABNUOWRM: {
+ NetSqlca sqlca = parseAbnormalEndUow
(resultSetI.getConnectionCallbackInterface());
+ resultSetI.completeSqlca (sqlca);
+ break;
+ }
+ case CodePoint.CMDCHKRM:
+ parseCMDCHKRM();
+ break;
+ case CodePoint.CMDNSPRM:
+ parseCMDNSPRM();
+ break;
+ case CodePoint.QRYNOPRM:
+ parseQRYNOPRM (resultSetI);
+ break;
+ case CodePoint.RDBNACRM:
+ parseRDBNACRM();
+ break;
+ default:
+ parseCommonError (peekCP);
+ }
+ }
+
+ //-----------------------------parse DDM Reply
Messages-----------------------
+
+ // Query Not Opened Reply Message is issued if a CNTQRY or CLSQRY
+ // command is issued for a query that is not open. A previous
+ // ENDQRYRM, ENDUOWRM, or ABNUOWRM reply message might have
+ // terminated the command.
+ // PROTOCOL architects the SQLSTATE value depending on SVRCOD
+ // SVRCOD 4 -> SQLSTATE is 24501
+ // SVRCOD 8 -> SQLSTATE of 58008 or 58009
+ //
+ // if SVRCOD is 4 then SQLSTATE 24501, SQLCODE -501
+ // else SQLSTATE 58009, SQLCODE -30020
+ //
+ // Messages
+ // SQLSTATE : 24501
+ // The identified cursor is not open.
+ // SQLCODE : -501
+ // The cursor specified in a FETCH or CLOSE statement is not open.
+ // The statement cannot be processed.
+ // 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 (4 - WARNING, 8 - ERROR)
+ // RDBNAM - required
+ // PKGNAMCSN - required
+ //
+ private void parseQRYNOPRM (ResultSetCallbackInterface resultSet) throws
DisconnectException
+ {
+ boolean svrcodReceived = false;
+ int svrcod = CodePoint.SVRCOD_INFO;
+ boolean rdbnamReceived = false;
+ String rdbnam = null;
+ boolean pkgnamcsnReceived = false;
+ Object pkgnamcsn = null;
+
+ parseLengthAndMatchCodePoint (CodePoint.QRYNOPRM);
+ 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 (peekCP == CodePoint.PKGNAMCSN) {
+ foundInPass = true;
+ pkgnamcsnReceived = checkAndGetReceivedFlag (pkgnamcsnReceived);
+ pkgnamcsn = parsePKGNAMCSN (true);
+ peekCP = peekCodePoint();
+ }
+
+ if (!foundInPass)
+ doPrmnsprmSemantics (peekCP);
+
+ }
+ popCollectionStack();
+ checkRequiredObjects (svrcodReceived, rdbnamReceived, pkgnamcsnReceived);
+
+ // move into a method
+ netAgent_.setSvrcod (svrcod);
+ if (svrcod == CodePoint.SVRCOD_WARNING) {
+ netAgent_.accumulateReadException (new SqlException
(netAgent_.logWriter_,
+ "The identified cursor is not open.",
+ SqlState._24501));
+ }
+ else {
+ agent_.accumulateChainBreakingReadExceptionAndThrow (new
DisconnectException (
+ agent_,
+ "Execution failed due to a distribution protocol error that " +
+ "caused deallocation of the conversation. " +
+ "The identified cursor is not open.",
+ SqlState._58009));
+ }
+ }
+}
+
Propchange:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetReply.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java
URL:
http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java?rev=165178&view=auto
==============================================================================
---
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java
(added)
+++
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java
Thu Apr 28 12:05:42 2005
@@ -0,0 +1,328 @@
+/*
+
+ Derby - Class org.apache.derby.client.net.NetResultSetRequest
+
+ 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.Section;
+import org.apache.derby.client.am.SqlException;
+import org.apache.derby.client.am.ResultSet;
+import org.apache.derby.client.am.ColumnMetaData;
+
+public class NetResultSetRequest extends NetStatementRequest
+ implements ResultSetRequestInterface
+{
+ public NetResultSetRequest (NetAgent netAgent, CcsidManager ccsidManager,
int bufferSize)
+ {
+ super (netAgent, ccsidManager, bufferSize);
+ }
+
+ //----------------------------- entry points
---------------------------------
+ public void writeFetch (NetResultSet resultSet,
+ Section section,
+ int fetchSize) throws SqlException
+ {
+ // - for forward-only cursors we do not send qryrowset on OPNQRY,
fetchSize is ignored.
+ // but qryrowset is sent on EXCSQLSTT for a stored procedure call.
+ boolean sendQryrowset =
+ ((NetStatement)
resultSet.statement_.materialStatement_).qryrowsetSentOnOpnqry_;
+
+ boolean sendRtnextdta = false;
+ if (sendQryrowset && resultSet.resultSetType_ ==
java.sql.ResultSet.TYPE_FORWARD_ONLY &&
+ ((NetCursor) resultSet.cursor_).hasLobs_) {
+ fetchSize = 1;
+ resultSet.fetchSize_ = 1;
+ sendRtnextdta = true;
+ ((NetCursor) resultSet.cursor_).rtnextrow_ = false;
+ }
+ // if one of the result sets returned from a stored procedure is
scrollable,
+ // then we set netStatement_.qryrowsetSentOnOpnqry_ to true even though we
didn't really
+ // send a qryrowset on excsqlstt for sqlam >= 7. this is ok for
scrollable cursors,
+ // but will cause a problem for forward-only cursors. Because if
fetchSize was never
+ // set, we will send qryrowset(0), which will cause a syntaxrm.
+ else if (resultSet.fetchSize_ == 0) {
+ sendQryrowset = false;
+ }
+
+ buildCNTQRY (section,
+ sendQryrowset,
+ resultSet.queryInstanceIdentifier_,
+ fetchSize,
+ sendRtnextdta);
+
+ buildOUTOVR (resultSet,
+ resultSet.resultSetMetaData_,
+ resultSet.firstOutovrBuilt_,
+ ((NetCursor) resultSet.cursor_).hasLobs_);
+ }
+
+ public void writeScrollableFetch (NetResultSet resultSet,
+ Section section,
+ int fetchSize,
+ int orientation,
+ long rowToFetch,
+ boolean resetQueryBlocks) throws
SqlException
+ {
+ int protocolOrientation = computePROTOCOLOrientation (orientation);
+
+ // - for sensitive-static cursors:
+ // * qryrowset must be sent on opnqry to indicate to the server that
the cursor is
+ // going to be used in a scrollable fashion. (sqlam<7)
+ // * if qryrowset is sent on opnqry, then it must be sent on all
subsequent cntqry's
+ // - for sensitive-dynamic non-rowset cursors: (we should never be in this
case)
+ // * qryrowset is NOT ALLOWED on cntqry's
+ // - for rowset cursors:
+ // * qryrowset is optional. it is ignored on opnqry. if not sent on
cntqry,
+ // then the fetch is going fetch next row as opposed to fetch next
rowset.
+ boolean sendQryrowset =
+ (resultSet.isRowsetCursor_ ||
+ (((NetStatement)
resultSet.statement_.materialStatement_).qryrowsetSentOnOpnqry_ &&
+ (resultSet.sensitivity_ == ResultSet.sensitivity_sensitive_static__
||
+ ((NetCursor)resultSet.cursor_).blocking_)));
+
+ buildScrollCNTQRY (protocolOrientation,
+ rowToFetch,
+ section,
+ sendQryrowset,
+ resultSet.queryInstanceIdentifier_,
+ fetchSize,
+ resetQueryBlocks);
+
+ buildOUTOVR (resultSet,
+ resultSet.resultSetMetaData_,
+ resultSet.firstOutovrBuilt_,
+ ((NetCursor) resultSet.cursor_).hasLobs_);
+ }
+
+ public void writePositioningFetch (NetResultSet resultSet,
+ Section section,
+ int orientation,
+ long rowToFetch) throws SqlException
+ {
+ int protocolOrientation = computePROTOCOLOrientation (orientation);
+
+ // do not send qryrowste if the cursor is a non-rowset, sensitive dynamic
cursor
+ boolean sendQryrowset =
+ resultSet.isRowsetCursor_ ||
+ (((NetStatement)
resultSet.statement_.materialStatement_).qryrowsetSentOnOpnqry_ &&
+ resultSet.sensitivity_ != resultSet.sensitivity_sensitive_dynamic__);
+
+ buildPositioningCNTQRY (protocolOrientation,
+ rowToFetch,
+ section,
+ sendQryrowset,
+ resultSet.queryInstanceIdentifier_,
+ resultSet.fetchSize_);
+
+ buildOUTOVR (resultSet,
+ resultSet.resultSetMetaData_,
+ resultSet.firstOutovrBuilt_,
+ ((NetCursor) resultSet.cursor_).hasLobs_);
+ }
+
+ public void writeCursorClose (NetResultSet resultSet,
+ Section section) throws SqlException
+ {
+ buildCLSQRY (section,
+ resultSet.queryInstanceIdentifier_);
+ }
+
+ //----------------------helper
methods----------------------------------------
+ // 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 buildCLSQRY (Section section,
+ long queryInstanceIdentifier)
+ throws SqlException
+ {
+ createCommand ();
+ markLengthBytes (CodePoint.CLSQRY);
+ buildPKGNAMCSN (section);
+ buildQRYINSID (queryInstanceIdentifier);
+ updateLengthBytes();
+ }
+
+ private void buildCNTQRY (Section section,
+ boolean sendQryrowset,
+ long queryInstanceIdentifier,
+ int qryrowsetSize,
+ boolean sendRtnextdta) throws SqlException
+ {
+ buildCoreCNTQRY (section,
+ sendQryrowset,
+ queryInstanceIdentifier,
+ qryrowsetSize);
+
+ // We will always let RTNEXTDTA default to RTNEXTROW. The only time we
need to send
+ // RTNEXTDTA RTNEXTALL is for a stored procedure returned forward-only
ResultSet
+ // that has LOB columns. Since there are LOBs in the
+ // ResultSet, no QRYDTA is returned on execute. On the CNTQRY's, we will
+ // send qryrowset(1) and rtnextall.
+ if (sendRtnextdta) buildRTNEXTDTA (CodePoint.RTNEXTALL);
+
+
+ updateLengthBytes();
+ }
+
+ // buildCoreCntqry builds the common parameters
+ private void buildCoreCNTQRY (Section section,
+ boolean sendQryrowset,
+ long queryInstanceIdentifier,
+ int qryrowsetSize)
+ throws SqlException
+ {
+ createCommand ();
+ markLengthBytes (CodePoint.CNTQRY);
+
+ buildPKGNAMCSN (section); // 1. packageNameAndConsistencyToken
+ buildQRYBLKSZ (); // 2. qryblksz
+
+ // maxblkext (-1) tells the server that the client is capable of receiving
any number of query blocks
+ if (sendQryrowset)
+ buildMAXBLKEXT (-1); // 3. maxblkext
+
+ // 4. qryinsid
+ buildQRYINSID (queryInstanceIdentifier);
+
+ if (sendQryrowset) buildQRYROWSET (qryrowsetSize); // 5. qryrowset
+ }
+
+ // Send CNTQRY to get a new rowset from the target server.
+ private void buildScrollCNTQRY (int scrollOrientation,
+ long rowNumber,
+ Section section,
+ boolean sendQryrowset,
+ long queryInstanceIdentifier,
+ int qryrowsetSize,
+ boolean resetQueryBlocks)
+ throws SqlException
+ {
+ buildCoreCNTQRY (section,
+ sendQryrowset,
+ queryInstanceIdentifier,
+ qryrowsetSize);
+
+ buildQRYSCRORN (scrollOrientation); // qryscrorn
+
+ if (scrollOrientation == CodePoint.QRYSCRABS || scrollOrientation ==
CodePoint.QRYSCRREL)
+ buildQRYROWNBR (rowNumber);
+
+ if (resetQueryBlocks)
+ buildQRYBLKRST (0xF1); // do reset the rowset
+ else
+ buildQRYBLKRST (0xF0); // do not reset the rowset
+
+ buildQRYRTNDTA (0xF1); // do return data
+
+ updateLengthBytes();
+ }
+
+ // Send CTNQRY to reposition the cursor on the target server.
+ private void buildPositioningCNTQRY (int scrollOrientation,
+ long rowNumber,
+ Section section,
+ boolean sendQryrowset,
+ long queryInstanceIdentifier,
+ int qryrowsetSize)
+ throws SqlException
+ {
+ createCommand ();
+ markLengthBytes (CodePoint.CNTQRY);
+
+ buildPKGNAMCSN (section); // 1. pkgnamcsn
+ buildQRYBLKSZ (); // 2. qryblksz
+
+ buildQRYINSID (queryInstanceIdentifier); // 3. qryinsid
+
+ if (sendQryrowset)
+ buildQRYROWSET (qryrowsetSize); // 4. qryrowset
+
+ buildQRYSCRORN (scrollOrientation); // 5. qryscrorn
+
+ if (scrollOrientation == CodePoint.QRYSCRABS || scrollOrientation ==
CodePoint.QRYSCRREL)
+ buildQRYROWNBR (rowNumber); // 6. qryrownbr
+
+ buildQRYBLKRST (0xF1); // 7. do reset the rowset
+ buildQRYRTNDTA (0xF0); // 8. do not return data
+
+
+ updateLengthBytes(); // for cntqry
+ }
+
+ private void buildOUTOVR (ResultSet resultSet,
+ ColumnMetaData resultSetMetaData,
+ boolean firstOutovrBuilt,
+ boolean hasLobs) throws SqlException
+ {
+ return;
+ }
+
+ private void buildRTNEXTDTA (int rtnextdta) throws SqlException
+ {
+ writeScalar1Byte (CodePoint.RTNEXTDTA, rtnextdta);
+ }
+
+ private void buildQRYSCRORN (int scrollOrientation) throws SqlException
+ {
+ writeScalar1Byte (CodePoint.QRYSCRORN, scrollOrientation);
+ }
+
+ private void buildQRYBLKRST (int qryblkrst) throws SqlException
+ {
+ writeScalar1Byte (CodePoint.QRYBLKRST, qryblkrst);
+ }
+
+ private void buildQRYROWNBR (long rowNumber) throws SqlException
+ {
+ writeScalar8Bytes (CodePoint.QRYROWNBR, rowNumber);
+ }
+
+ private void buildQRYRTNDTA (int qryrtndta) throws SqlException
+ {
+ writeScalar1Byte (CodePoint.QRYRTNDTA, qryrtndta);
+ }
+
+ //----------------------non-parsing computational helper
methods--------------
+ // 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.
+
+ // Called by NetResultSetRequest.writeScrollableFetch()
+ private int computePROTOCOLOrientation (int orientation) throws SqlException
+ {
+ switch (orientation) {
+ case ResultSet.scrollOrientation_absolute__ :
+ return CodePoint.QRYSCRABS;
+
+ case ResultSet.scrollOrientation_after__ :
+ return CodePoint.QRYSCRAFT;
+
+ case ResultSet.scrollOrientation_before__ :
+ return CodePoint.QRYSCRBEF;
+
+ case ResultSet.scrollOrientation_relative__ :
+ return CodePoint.QRYSCRREL;
+
+ default:
+ throw new SqlException (netAgent_.logWriter_, "Bug check: invalid scroll
orientation");
+ }
+ }
+
+}
Propchange:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetResultSetRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqlca.java
URL:
http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqlca.java?rev=165178&view=auto
==============================================================================
---
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqlca.java
(added)
+++
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqlca.java
Thu Apr 28 12:05:42 2005
@@ -0,0 +1,66 @@
+/*
+
+ Derby - Class org.apache.derby.client.net.NetSqlca
+
+ 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.Sqlca;
+
+public class NetSqlca extends Sqlca
+{
+ // these are the same variables that are in the Sqlca except ccsids
+ // are a little different
+
+ NetSqlca (org.apache.derby.client.am.Connection connection,
+ int sqlCode,
+ byte[] sqlStateBytes,
+ byte[] sqlErrpBytes,
+ int ccsid)
+ {
+ super(connection);
+ sqlCode_ = sqlCode;
+ sqlStateBytes_ = sqlStateBytes;
+ sqlErrpBytes_ = sqlErrpBytes;
+ ccsid_ = ccsid;
+ }
+
+ protected void setSqlerrd (int[] sqlErrd)
+ {
+ sqlErrd_ = sqlErrd;
+ }
+
+ protected void setSqlwarnBytes (byte[] sqlWarnBytes)
+ {
+ sqlWarnBytes_ = sqlWarnBytes;
+ }
+
+ protected void setSqlerrmcBytes (byte[] sqlErrmcBytes, int sqlErrmcCcsid)
+ {
+ sqlErrmcBytes_ = sqlErrmcBytes;
+ sqlErrmcCcsid_ = sqlErrmcCcsid;
+ }
+
+ public long getRowCount (Typdef typdef) throws
org.apache.derby.client.am.DisconnectException
+ {
+ int byteOrder = typdef.getByteOrder();
+ long num = (byteOrder ==
org.apache.derby.client.am.SignedBinary.BIG_ENDIAN) ?
+ super.getRowCount() : ((long)sqlErrd_[1]<<32) + sqlErrd_[0];
+ return num;
+ }
+}
Propchange:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqlca.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqldta.java
URL:
http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqldta.java?rev=165178&view=auto
==============================================================================
---
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqldta.java
(added)
+++
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqldta.java
Thu Apr 28 12:05:42 2005
@@ -0,0 +1,159 @@
+/*
+
+ Derby - Class org.apache.derby.client.net.NetSqldta
+
+ 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;
+
+
+
+public class NetSqldta extends NetCursor
+{
+ private NetConnection netConnection_;
+
+
+ public NetSqldta (NetAgent netAgent)
+ {
+ super (netAgent);
+ netConnection_ = netAgent.netConnection_;
+ }
+
+ public boolean next () throws org.apache.derby.client.am.SqlException
+ {
+ if (allRowsReceivedFromServer_)
+ return false;
+ else {
+ allRowsReceivedFromServer_ = true;
+ return true;
+ }
+ }
+
+ protected boolean calculateColumnOffsetsForRow ()
+ {
+ int colNullIndicator = CodePoint.NULLDATA;
+ int length ;
+
+ extdtaPositions_.clear(); // reset positions for this row
+
+ // read the da null indicator
+ if (readFdocaOneByte() == 0xff)
+ return false;
+
+ incrementRowsReadEvent();
+ // Use the arrays defined on the Cursor for forward-only cursors.
+ // can they ever be null
+ if (columnDataPosition_ == null || columnDataComputedLength_ == null ||
isNull_ == null)
+ allocateColumnOffsetAndLengthArrays ();
+
+ // Loop through the columns
+ for (int index = 0; index < columns_; index++) {
+ // If column is nullable, read the 1-byte null indicator.
+ if (nullable_[index])
+ // Need to pass the column index so all previously calculated offsets
can be
+ // readjusted if the query block splits on a column null indicator.
+
+ // null indicators from FD:OCA data
+ // 0 to 127: a data value will flow.
+ // -1 to -128: no data value will flow.
+ colNullIndicator = readFdocaOneByte ();
+
+ // If non-null column data
+ if (!nullable_[index] || (colNullIndicator >= 0 && colNullIndicator <=
127)) {
+ isNull_[index] = false;
+
+ switch (typeToUseForComputingDataLength_[index]) {
+ // for variable character string and variable byte string,
+ // there are 2-byte of length in front of the data
+ case Typdef.TWOBYTELENGTH:
+ columnDataPosition_[index] = position_;
+ length = readFdocaTwoByteLength ();
+ // skip length + the 2-byte length field
+ if (isGraphic_[index])
+ columnDataComputedLength_[index] = skipFdocaBytes (length*2) + 2;
+ else
+ columnDataComputedLength_[index] = skipFdocaBytes (length) + 2;
+ break;
+
+ // for short variable character string and short variable byte
string,
+ // there is a 1-byte length in front of the data
+ case Typdef.ONEBYTELENGTH:
+ columnDataPosition_[index] = position_;
+ length = readFdocaOneByte ();
+ // skip length + the 1-byte length field
+ if (isGraphic_[index])
+ columnDataComputedLength_[index] = skipFdocaBytes (length*2) + 1;
+ else
+ columnDataComputedLength_[index] = skipFdocaBytes (length) + 1;
+ break;
+
+ // For decimal columns, determine the precision, scale, and the
representation
+ case Typdef.DECIMALLENGTH:
+ columnDataPosition_[index] = position_;
+ columnDataComputedLength_[index] = skipFdocaBytes
(getDecimalLength(index));
+ break;
+
+ case Typdef.LOBLENGTH:
+ columnDataPosition_[index] = position_;
+ columnDataComputedLength_[index] = this.skipFdocaBytes
(fdocaLength_[index] & 0x7fff);
+ break;
+
+ default:
+ columnDataPosition_[index] = position_;
+ if (isGraphic_[index])
+ columnDataComputedLength_[index] = skipFdocaBytes
(fdocaLength_[index]*2);
+ else
+ columnDataComputedLength_[index] = skipFdocaBytes
(fdocaLength_[index]);
+ break;
+ }
+ }
+ else if ((colNullIndicator & 0x80) == 0x80) {
+ // Null data. Set the isNull indicator to true.
+ isNull_[index] = true;
+ }
+ }
+
+ if (!allRowsReceivedFromServer_)
+ calculateLobColumnPositionsForRow();
+
+ return true; // hardwired for now, this means the current row position is
a valid position
+ }
+
+
+
+ private int skipFdocaBytes (int length)
+ {
+ position_ += length;
+ return length;
+ }
+
+ private int readFdocaOneByte ()
+ {
+ return dataBuffer_[position_++] & 0xff;
+ }
+
+
+ private int readFdocaTwoByteLength ()
+ {
+ return
+ ((dataBuffer_[position_++] & 0xff) << 8) +
+ ((dataBuffer_[position_++] & 0xff) << 0);
+ }
+
+
+}
+
Propchange:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetSqldta.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatement.java
URL:
http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatement.java?rev=165178&view=auto
==============================================================================
---
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatement.java
(added)
+++
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatement.java
Thu Apr 28 12:05:42 2005
@@ -0,0 +1,185 @@
+/*
+
+ Derby - Class org.apache.derby.client.net.NetStatement
+
+ 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.Section;
+import org.apache.derby.client.am.ColumnMetaData;
+import org.apache.derby.client.am.Statement;
+import org.apache.derby.client.am.SqlException;
+
+public class NetStatement implements
org.apache.derby.client.am.MaterialStatement
+{
+
+ Statement statement_;
+
+
+ // Alias for (NetConnection) statement_.connection
+ NetConnection netConnection_;
+
+ // Alias for (NetAgent) statement_.agent
+ NetAgent netAgent_;
+
+
+ // If qryrowset is sent on opnqry then it also needs to be sent on every
subsequent cntqry.
+ public boolean qryrowsetSentOnOpnqry_ = false;
+
+
//---------------------constructors/finalizer---------------------------------
+
+ private NetStatement()
+ {
+ initNetStatement();
+ }
+
+ private void resetNetStatement()
+ {
+ initNetStatement();
+ }
+
+ private void initNetStatement()
+ {
+ qryrowsetSentOnOpnqry_ = false;
+ }
+
+ // Relay constructor for NetPreparedStatement.
+ NetStatement (org.apache.derby.client.am.Statement statement, NetAgent
netAgent, NetConnection netConnection)
+ {
+ this();
+ initNetStatement (statement, netAgent, netConnection);
+ }
+
+ void resetNetStatement (org.apache.derby.client.am.Statement statement,
NetAgent netAgent, NetConnection netConnection)
+ {
+ resetNetStatement();
+ initNetStatement (statement, netAgent, netConnection);
+ }
+
+ private void initNetStatement (org.apache.derby.client.am.Statement
statement, NetAgent netAgent, NetConnection netConnection)
+ {
+ netAgent_ = netAgent;
+ netConnection_ = netConnection;
+ statement_ = statement;
+ statement_.materialStatement_ = this;
+ }
+
+ // Called by abstract Connection.createStatement().newStatement() for jdbc 1
statements
+ NetStatement (NetAgent netAgent, NetConnection netConnection) throws
SqlException
+ {
+ this (new Statement (netAgent, netConnection),
+ netAgent,
+ netConnection);
+ }
+
+ void netReset (NetAgent netAgent, NetConnection netConnection) throws
SqlException
+ {
+ statement_.resetStatement(netAgent, netConnection);
+ resetNetStatement (statement_, netAgent, netConnection);
+ }
+
+ public void reset_ ()
+ {
+ qryrowsetSentOnOpnqry_ = false;
+ }
+
+ // Called by abstract Connection.createStatement().newStatement() for jdbc 2
statements with scroll attributes
+ NetStatement (NetAgent netAgent, NetConnection netConnection, int type, int
concurrency, int holdability) throws SqlException
+ {
+ this (new Statement (netAgent, netConnection, type, concurrency,
holdability, java.sql.Statement.NO_GENERATED_KEYS, null),
+ netAgent,
+ netConnection);
+ }
+
+ void resetNetStatement (NetAgent netAgent, NetConnection netConnection, int
type, int concurrency, int holdability) throws SqlException
+ {
+ statement_.resetStatement(netAgent, netConnection, type, concurrency,
holdability, java.sql.Statement.NO_GENERATED_KEYS,null);
+ resetNetStatement (statement_, netAgent, netConnection);
+ }
+
+ protected void finalize () throws java.lang.Throwable
+ {
+ super.finalize();
+ }
+
+ // ------------------------abstract box car
methods-----------------------------------------------
+
+ public void writeSetSpecialRegister_ (java.util.ArrayList sqlsttList) throws
SqlException
+ { netAgent_.statementRequest_.writeSetSpecialRegister (sqlsttList); }
+ public void readSetSpecialRegister_ () throws SqlException
+ { netAgent_.statementReply_.readSetSpecialRegister (statement_); }
+ public void writeExecuteImmediate_ (String sql,
+ Section section) throws SqlException
+ { netAgent_.statementRequest_.writeExecuteImmediate (this, sql, section); }
+ public void readExecuteImmediate_ () throws SqlException
+ { netAgent_.statementReply_.readExecuteImmediate (statement_); }
+
+ // NOTE: NET processing does not require parameters supplied on the
"read-side" so parameter sql is ignored.
+ public void readExecuteImmediateForBatch_ (String sql) throws SqlException
+ { readExecuteImmediate_(); }
+
+ public void writePrepareDescribeOutput_ (String sql,
+ Section section) throws SqlException
+ { netAgent_.statementRequest_.writePrepareDescribeOutput (this, sql,
section); }
+ public void readPrepareDescribeOutput_ () throws SqlException
+ { netAgent_.statementReply_.readPrepareDescribeOutput (statement_); }
+
+ public void writeOpenQuery_ (Section section,
+ int fetchSize,
+ int resultSetType)
+ throws SqlException
+ {
+ netAgent_.statementRequest_.writeOpenQuery (
+ this,
+ section,
+ fetchSize,
+ resultSetType);
+ }
+ public void readOpenQuery_ () throws SqlException
+ { netAgent_.statementReply_.readOpenQuery (statement_); }
+
+ public void writeExecuteCall_ (boolean outputExpected,
+ String procedureName,
+ Section section,
+ int fetchSize,
+ boolean suppressResultSets,
+ int resultSetType,
+ ColumnMetaData parameterMetaData,
+ Object[] inputs) throws SqlException
+ {
+ netAgent_.statementRequest_.writeExecuteCall (
+ this,
+ outputExpected,
+ procedureName,
+ section,
+ fetchSize,
+ suppressResultSets,
+ resultSetType,
+ parameterMetaData,
+ inputs);
+ }
+ public void readExecuteCall_ () throws SqlException
+ { netAgent_.statementReply_.readExecuteCall (statement_); }
+
+ public void writePrepare_ (String sql, Section section) throws SqlException
+ { netAgent_.statementRequest_.writePrepare (this, sql, section); }
+ public void readPrepare_ () throws SqlException
+ { netAgent_.statementReply_.readPrepare (statement_); }
+
+ public void markClosedOnServer_ () {}
+}
Propchange:
incubator/derby/code/trunk/java/client/org/apache/derby/client/net/NetStatement.java
------------------------------------------------------------------------------
svn:eol-style = native