KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > client > net > NetPackageReply


1 /*
2
3    Derby - Class org.apache.derby.client.net.NetPackageReply
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to You under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20 */

21
22 package org.apache.derby.client.net;
23
24 import org.apache.derby.client.am.DisconnectException;
25 import org.apache.derby.client.am.ClientMessageId;
26 import org.apache.derby.shared.common.reference.SQLState;
27
28 public class NetPackageReply extends NetConnectionReply {
29     NetPackageReply(NetAgent netAgent, int bufferSize) {
30         super(netAgent, bufferSize);
31     }
32
33
34     NetSqlca parseSqlErrorCondition() throws DisconnectException {
35         parseSQLERRRM();
36         parseTypdefsOrMgrlvlovrs();
37         NetSqlca netSqlca = parseSQLCARD(null);
38         return netSqlca;
39     }
40
41
42     // Also called by NetStatementReply
43
void parseDTAMCHRM() throws DisconnectException {
44         boolean svrcodReceived = false;
45         int svrcod = CodePoint.SVRCOD_INFO;
46         boolean rdbnamReceived = false;
47         String JavaDoc rdbnam = null;
48
49         parseLengthAndMatchCodePoint(CodePoint.DTAMCHRM);
50         pushLengthOnCollectionStack();
51         int peekCP = peekCodePoint();
52
53         while (peekCP != Reply.END_OF_COLLECTION) {
54
55             boolean foundInPass = false;
56
57             if (peekCP == CodePoint.SVRCOD) {
58                 foundInPass = true;
59                 svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
60                 svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
61                 peekCP = peekCodePoint();
62             }
63
64             if (peekCP == CodePoint.RDBNAM) {
65                 foundInPass = true;
66                 rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
67                 rdbnam = parseRDBNAM(true);
68                 peekCP = peekCodePoint();
69             }
70
71             if (!foundInPass) {
72                 doPrmnsprmSemantics(peekCP);
73             }
74
75         }
76         popCollectionStack();
77         checkRequiredObjects(svrcodReceived, rdbnamReceived);
78
79         netAgent_.setSvrcod(svrcod);
80         doDtamchrmSemantics();
81     }
82
83     // RDB Update Reply Message indicates that a DDM command resulted
84
// in an update at the target relational database. If a command
85
// generated multiple reply messages including an RDBUPDRM, then
86
// the RDBUPDRM must be the first reply message for the command.
87
// For each target server, the RDBUPDRM must be returned the first
88
// time an update is made to the target RDB within a unit of work.
89
// The target server may optionally return the RDBUPDRM after subsequent
90
// updates within the UOW. If multiple target RDBs are involved with
91
// the current UOW and updates are made with any of them, then the RDBUPDRM
92
// must be returned in response to the first update at each of them.
93
protected void parseRDBUPDRM() throws DisconnectException {
94         boolean svrcodReceived = false;
95         int svrcod = CodePoint.SVRCOD_INFO;
96         boolean rdbnamReceived = false;
97         String JavaDoc rdbnam = null;
98
99         parseLengthAndMatchCodePoint(CodePoint.RDBUPDRM);
100         pushLengthOnCollectionStack();
101
102         // in XA Global transaction we need to know if we have a read-only
103
// transaction, if we get a RDBUPDRM this is NOT a read-only transaction
104
// currently only XAConnections care about read-only transactions, if
105
// non-XA wants this information they will need to initialize the flag
106
// at start of UOW
107
netAgent_.netConnection_.setReadOnlyTransactionFlag(false);
108
109         int peekCP = peekCodePoint();
110
111         while (peekCP != Reply.END_OF_COLLECTION) {
112
113             boolean foundInPass = false;
114
115             if (peekCP == CodePoint.SVRCOD) {
116                 foundInPass = true;
117                 svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
118                 svrcod = parseSVRCOD(CodePoint.SVRCOD_INFO, CodePoint.SVRCOD_INFO);
119                 peekCP = peekCodePoint();
120             }
121
122             if (peekCP == CodePoint.RDBNAM) {
123                 foundInPass = true;
124                 rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
125                 rdbnam = parseRDBNAM(true);
126                 peekCP = peekCodePoint();
127             }
128
129             if (!foundInPass) {
130                 doPrmnsprmSemantics(peekCP);
131             }
132
133         }
134         popCollectionStack();
135         checkRequiredObjects(svrcodReceived, rdbnamReceived);
136
137         // call an event to indicate the server has been updated
138
netAgent_.setSvrcod(svrcod);
139
140     }
141
142     // SQL Error Condition Reply Message indicates that an SQL error
143
// has occurred. It may be sent even though no reply message
144
// precedes the SQLCARD object that is the normal
145
// response to a command when an exception occurs.
146
// The SQLERRM is also used when a BNDSQLSTT command is terminated
147
// by an INTRRDBRQS command.
148
// This reply message must precede an SQLCARD object.
149
// The SQLSTATE is returned in the SQLCARD.
150
//
151
// Returned from Server:
152
// SVRCOD - required (8 - ERROR)
153
// RDBNAM - optional
154
//
155
// Also called by NetResultSetReply and NetStatementReply
156
void parseSQLERRRM() throws DisconnectException {
157         boolean svrcodReceived = false;
158         int svrcod = CodePoint.SVRCOD_INFO;
159         boolean rdbnamReceived = false;
160         String JavaDoc rdbnam = null;
161
162         parseLengthAndMatchCodePoint(CodePoint.SQLERRRM);
163         pushLengthOnCollectionStack();
164         int peekCP = peekCodePoint();
165
166         while (peekCP != Reply.END_OF_COLLECTION) {
167
168             boolean foundInPass = false;
169
170             if (peekCP == CodePoint.SVRCOD) {
171                 foundInPass = true;
172                 svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
173                 svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
174                 peekCP = peekCodePoint();
175             }
176
177             if (peekCP == CodePoint.RDBNAM) {
178                 foundInPass = true;
179                 rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
180                 rdbnam = parseRDBNAM(true);
181                 peekCP = peekCodePoint();
182             }
183
184             if (!foundInPass) {
185                 doPrmnsprmSemantics(peekCP);
186             }
187
188         }
189         popCollectionStack();
190         checkRequiredObjects(svrcodReceived);
191
192         // move into a method
193
netAgent_.setSvrcod(svrcod);
194     }
195
196     //--------------------- parse DDM Reply Data--------------------------------------
197

198     //------------------------parse DDM Scalars-----------------------------
199

200     // RDB Package Name and Consistency token Scalar Object specifies the
201
// fully qualified name of a relational database package and its
202
// consistency token.
203
protected Object JavaDoc parsePKGNAMCT(boolean skip) throws DisconnectException {
204         parseLengthAndMatchCodePoint(CodePoint.PKGNAMCT);
205         if (skip) {
206             skipBytes();
207             return null;
208         }
209         agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
210                 new ClientMessageId(SQLState.DRDA_COMMAND_NOT_IMPLEMENTED),
211                 "parsePKGNAMCT"));
212         return null; // to make compiler happy
213
}
214 }
215
Popular Tags