KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Derby - Class org.apache.derby.client.net.NetConnectionReply
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 javax.transaction.xa.Xid JavaDoc;
25
26 import org.apache.derby.client.am.Connection;
27 import org.apache.derby.client.am.ConnectionCallbackInterface;
28 import org.apache.derby.client.am.StatementCallbackInterface;
29 import org.apache.derby.client.am.ResultSetCallbackInterface;
30 import org.apache.derby.client.am.DisconnectException;
31 import org.apache.derby.client.am.SqlException;
32 import org.apache.derby.client.am.ClientMessageId;
33 import org.apache.derby.client.am.Sqlca;
34 import java.io.UnsupportedEncodingException JavaDoc;
35 import org.apache.derby.client.am.UnitOfWorkListener;
36
37 import org.apache.derby.shared.common.error.ExceptionSeverity;
38 import org.apache.derby.shared.common.error.ExceptionUtil;
39 import org.apache.derby.shared.common.reference.SQLState;
40 import org.apache.derby.shared.common.reference.MessageId;
41 import org.apache.derby.shared.common.i18n.MessageUtil;
42
43
44 public class NetConnectionReply extends Reply
45         implements ConnectionReplyInterface {
46     private static MessageUtil msgutil_ = SqlException.getMessageUtil();
47     
48     NetConnectionReply(NetAgent netAgent, int bufferSize) {
49         super(netAgent, bufferSize);
50     }
51
52     // NET only entry point
53
void readExchangeServerAttributes(Connection connection) throws SqlException {
54         startSameIdChainParse();
55         parseEXCSATreply((NetConnection) connection);
56         endOfSameIdChainData();
57         agent_.checkForChainBreakingException_();
58     }
59
60     void verifyDeferredReset() throws SqlException {
61         readDssHeader();
62         verifyConnectReply(CodePoint.EXCSATRD);
63         readDssHeader();
64         verifyConnectReply(CodePoint.ACCSECRD);
65         readDssHeader();
66         verifyConnectReply(CodePoint.SECCHKRM);
67         readDssHeader();
68         verifyConnectReply(CodePoint.ACCRDBRM);
69         agent_.checkForChainBreakingException_();
70     }
71
72     void verifyConnectReply(int codept) throws SqlException {
73         if (peekCodePoint() != codept) {
74             parseConnectError();
75             return;
76         }
77         readLengthAndCodePoint();
78         skipBytes();
79
80         if (codept == CodePoint.ACCRDBRM) {
81             int peekCP = peekCodePoint();
82             if (peekCP == Reply.END_OF_SAME_ID_CHAIN) {
83                 return;
84             }
85
86             parseTypdefsOrMgrlvlovrs();
87             NetSqlca netSqlca = parseSQLCARD(null);
88             netAgent_.netConnection_.completeSqlca(netSqlca);
89         }
90     }
91
92     void parseConnectError() throws DisconnectException {
93         int peekCP = peekCodePoint();
94         switch (peekCP) {
95         case CodePoint.CMDCHKRM:
96             parseCMDCHKRM();
97             break;
98         case CodePoint.MGRLVLRM:
99             parseMGRLVLRM();
100             break;
101         default:
102             parseCommonError(peekCP);
103         }
104     }
105
106     void readDummyExchangeServerAttributes(Connection connection) throws SqlException {
107         startSameIdChainParse();
108         parseDummyEXCSATreply((NetConnection) connection);
109         endOfSameIdChainData();
110         agent_.checkForChainBreakingException_();
111     }
112
113     // NET only entry point
114
void readAccessSecurity(Connection connection,
115                             int securityMechanism) throws SqlException {
116         startSameIdChainParse();
117         parseACCSECreply((NetConnection) connection, securityMechanism);
118         endOfSameIdChainData();
119         agent_.checkForChainBreakingException_();
120     }
121
122     // NET only entry point
123
void readSecurityCheck(Connection connection) throws SqlException {
124         startSameIdChainParse();
125         parseSECCHKreply((NetConnection) connection);
126         endOfSameIdChainData();
127         agent_.checkForChainBreakingException_();
128     }
129
130     // NET only entry point
131
void readAccessDatabase(Connection connection) throws SqlException {
132         startSameIdChainParse();
133         parseACCRDBreply((NetConnection) connection);
134         endOfSameIdChainData();
135         agent_.checkForChainBreakingException_();
136     }
137
138
139     public void readCommitSubstitute(ConnectionCallbackInterface connection) throws DisconnectException {
140         startSameIdChainParse();
141         parseDummyEXCSATreply((NetConnection) connection);
142         endOfSameIdChainData();
143     }
144
145     public void readLocalCommit(ConnectionCallbackInterface connection) throws DisconnectException {
146         startSameIdChainParse();
147         parseRDBCMMreply(connection);
148         endOfSameIdChainData();
149     }
150
151     public void readLocalRollback(ConnectionCallbackInterface connection) throws DisconnectException {
152         startSameIdChainParse();
153         parseRDBRLLBCKreply(connection);
154         endOfSameIdChainData();
155     }
156
157
158     public void readLocalXAStart(ConnectionCallbackInterface connection) throws DisconnectException {
159     }
160
161     public void readLocalXACommit(ConnectionCallbackInterface connection) throws DisconnectException {
162     }
163
164     public void readLocalXARollback(ConnectionCallbackInterface connection) throws DisconnectException {
165     }
166
167
168     protected void readXaStartUnitOfWork(NetConnection conn) throws DisconnectException {
169     }
170
171     protected int readXaEndUnitOfWork(NetConnection conn) throws DisconnectException {
172         return 0;
173     }
174
175     protected int readXaPrepare(NetConnection conn) throws DisconnectException {
176         return 0;
177     }
178
179     protected void readXaCommit(NetConnection conn) throws DisconnectException {
180     }
181
182     protected int readXaRollback(NetConnection conn) throws DisconnectException {
183         return 0;
184     }
185
186     protected void readXaRecover(NetConnection conn) throws DisconnectException {
187     }
188
189     protected void readXaForget(NetConnection conn) throws DisconnectException {
190     }
191
192
193     //------------------parse reply for specific command--------------------------
194
// These methods are "private protected", which is not a recognized java privilege,
195
// but means that these methods are private to this class and to subclasses,
196
// and should not be used as package-wide friendly methods.
197

198     // Parse the reply for the RDB Commit Unit of Work Command.
199
// This method handles the parsing of all command replies and reply data
200
// for the rdbcmm command.
201
private void parseRDBCMMreply(ConnectionCallbackInterface connection) throws DisconnectException {
202         int peekCP = parseTypdefsOrMgrlvlovrs();
203
204         if (peekCP != CodePoint.ENDUOWRM && peekCP != CodePoint.SQLCARD) {
205             parseCommitError(connection);
206             return;
207         }
208
209         if (peekCP == CodePoint.ENDUOWRM) {
210             parseENDUOWRM(connection);
211             peekCP = parseTypdefsOrMgrlvlovrs();
212         }
213
214         NetSqlca netSqlca = parseSQLCARD(null);
215         connection.completeSqlca(netSqlca);
216     }
217
218     // Parse the reply for the RDB Rollback Unit of Work Command.
219
// This method handles the parsing of all command replies and reply data
220
// for the rdbrllbck command.
221
private void parseRDBRLLBCKreply(ConnectionCallbackInterface connection) throws DisconnectException {
222         int peekCP = parseTypdefsOrMgrlvlovrs();
223         if (peekCP != CodePoint.ENDUOWRM) {
224             parseRollbackError();
225             return;
226         }
227
228         parseENDUOWRM(connection);
229         peekCP = parseTypdefsOrMgrlvlovrs();
230
231         NetSqlca netSqlca = parseSQLCARD(null);
232         connection.completeSqlca(netSqlca);
233     }
234
235     // Parse the reply for the Exchange Server Attributes Command.
236
// This method handles the parsing of all command replies and reply data
237
// for the excsat command.
238
private void parseEXCSATreply(NetConnection netConnection) throws DisconnectException {
239         if (peekCodePoint() != CodePoint.EXCSATRD) {
240             parseExchangeServerAttributesError();
241             return;
242         }
243         parseEXCSATRD(netConnection);
244     }
245
246     // Parse the reply for the Exchange Server Attributes Command (Dummy)
247
// This method handles the parsing of all command replies and reply data
248
// for the excsat command.
249
private void parseDummyEXCSATreply(NetConnection netConnection) throws DisconnectException {
250         if (peekCodePoint() != CodePoint.EXCSATRD) {
251             parseExchangeServerAttributesError();
252             return;
253         }
254         parseDummyEXCSATRD(netConnection);
255     }
256
257     // Parse the reply for the Access Security Command.
258
// This method handles the parsing of all command replies and reply data
259
// for the accsec command.
260
private void parseACCSECreply(NetConnection netConnection, int securityMechanism) throws DisconnectException {
261         int peekCP = peekCodePoint();
262         if (peekCP != CodePoint.ACCSECRD) {
263             parseAccessSecurityError(netConnection);
264             return;
265         }
266         parseACCSECRD(netConnection, securityMechanism);
267
268         peekCP = peekCodePoint();
269         if (peekCP == Reply.END_OF_SAME_ID_CHAIN) {
270             return;
271         }
272
273     }
274
275     // Parse the reply for the Security Check Command.
276
// This method handles the parsing of all command replies and reply data
277
// for the secchk command.
278
private void parseSECCHKreply(NetConnection netConnection) throws DisconnectException {
279         if (peekCodePoint() != CodePoint.SECCHKRM) {
280             parseSecurityCheckError(netConnection);
281             return;
282         }
283
284         parseSECCHKRM(netConnection);
285         if (peekCodePoint() == CodePoint.SECTKN) {
286             // rpydta used only if the security mechanism returns
287
// a security token that must be sent back to the source system.
288
// this is only used for DCSSEC. In the case of DCESEC,
289
// the sectkn must be returned as reply data if DCE is using
290
// mutual authentication.
291
// Need to double check what to map this to. This is probably
292
// incorrect but consider it a conversation protocol error
293
// 0x03 - OBJDSS sent when not allowed.
294
//parseSECTKN (true);
295
boolean done = false;
296             byte[] bytes = parseSECTKN(false);
297         }
298     }
299
300     // Parse the reply for the Access RDB Command.
301
// This method handles the parsing of all command replies and reply data
302
// for the accrdb command.
303
private void parseACCRDBreply(NetConnection netConnection) throws DisconnectException {
304         int peekCP = peekCodePoint();
305         if (peekCP != CodePoint.ACCRDBRM) {
306             parseAccessRdbError(netConnection);
307             return;
308         }
309
310         parseACCRDBRM(netConnection);
311         peekCP = peekCodePoint();
312         if (peekCP == Reply.END_OF_SAME_ID_CHAIN) {
313             return;
314         }
315
316         parseTypdefsOrMgrlvlovrs();
317         NetSqlca netSqlca = parseSQLCARD(null);
318         netConnection.completeSqlca(netSqlca);
319     }
320
321
322     protected int parseTypdefsOrMgrlvlovrs() throws DisconnectException {
323         boolean targetTypedefCloned = false;
324         while (true) {
325             int peekCP = peekCodePoint();
326             if (peekCP == CodePoint.TYPDEFNAM) {
327                 if (!targetTypedefCloned) {
328                     netAgent_.targetTypdef_ = (Typdef) netAgent_.targetTypdef_.clone();
329                     targetTypedefCloned = true;
330                 }
331                 parseTYPDEFNAM();
332             } else if (peekCP == CodePoint.TYPDEFOVR) {
333                 if (!targetTypedefCloned) {
334                     netAgent_.targetTypdef_ = (Typdef) netAgent_.targetTypdef_.clone();
335                     targetTypedefCloned = true;
336                 }
337                 parseTYPDEFOVR();
338             } else {
339                 return peekCP;
340             }
341         }
342     }
343
344
345     //-----------------------------parse DDM Reply Messages-----------------------
346

347     protected void parseCommitError(ConnectionCallbackInterface connection) throws DisconnectException {
348         int peekCP = peekCodePoint();
349         switch (peekCP) {
350         case CodePoint.ABNUOWRM:
351             NetSqlca sqlca = parseAbnormalEndUow(connection,null);
352             connection.completeSqlca(sqlca);
353             break;
354         case CodePoint.CMDCHKRM:
355             parseCMDCHKRM();
356             break;
357         case CodePoint.RDBNACRM:
358             parseRDBNACRM();
359             break;
360         default:
361             parseCommonError(peekCP);
362             break;
363         }
364     }
365
366     void parseRollbackError() throws DisconnectException {
367         int peekCP = peekCodePoint();
368         switch (peekCP) {
369         case CodePoint.CMDCHKRM:
370             parseCMDCHKRM();
371             break;
372         case CodePoint.RDBNACRM:
373             parseRDBNACRM();
374             break;
375         default:
376             parseCommonError(peekCP);
377             break;
378         }
379     }
380
381     void parseExchangeServerAttributesError() throws DisconnectException {
382         int peekCP = peekCodePoint();
383         switch (peekCP) {
384         case CodePoint.CMDCHKRM:
385             parseCMDCHKRM();
386             break;
387         case CodePoint.MGRLVLRM:
388             parseMGRLVLRM();
389             break;
390         default:
391             parseCommonError(peekCP);
392         }
393     }
394
395     void parseAccessSecurityError(NetConnection netConnection) throws DisconnectException {
396         int peekCP = peekCodePoint();
397         switch (peekCP) {
398         case CodePoint.CMDCHKRM:
399             parseCMDCHKRM();
400             break;
401         case CodePoint.RDBNFNRM:
402             parseRDBNFNRM(netConnection);
403             break;
404         case CodePoint.RDBAFLRM:
405             parseRdbAccessFailed(netConnection);
406             break;
407         default:
408             parseCommonError(peekCP);
409         }
410     }
411
412     void parseSecurityCheckError(NetConnection netConnection) throws DisconnectException {
413         int peekCP = peekCodePoint();
414         switch (peekCP) {
415         case CodePoint.CMDCHKRM:
416             parseCMDCHKRM();
417             break;
418         case CodePoint.OBJNSPRM:
419             parseOBJNSPRM();
420             break;
421         case CodePoint.RDBNFNRM:
422             parseRDBNFNRM(netConnection);
423             break;
424         case CodePoint.RDBAFLRM:
425             parseRdbAccessFailed(netConnection);
426             break;
427         default:
428             parseCommonError(peekCP);
429         }
430     }
431
432     void parseAccessRdbError(NetConnection netConnection) throws DisconnectException {
433         int peekCP = peekCodePoint();
434         switch (peekCP) {
435         case CodePoint.CMDCHKRM:
436             parseCMDCHKRM();
437             break;
438         case CodePoint.RDBACCRM:
439             parseRDBACCRM();
440             break;
441         case CodePoint.RDBAFLRM:
442             parseRdbAccessFailed(netConnection);
443             break;
444         case CodePoint.RDBATHRM:
445             parseRDBATHRM(netConnection);
446             break;
447         case CodePoint.RDBNFNRM:
448             parseRDBNFNRM(netConnection);
449             break;
450         default:
451             parseCommonError(peekCP);
452         }
453     }
454
455
456     // Called by all the NET*Reply classes.
457
void parseCommonError(int peekCP) throws DisconnectException {
458         switch (peekCP) {
459         case CodePoint.CMDNSPRM:
460             parseCMDNSPRM();
461             break;
462         case CodePoint.PRCCNVRM:
463             parsePRCCNVRM();
464             break;
465         case CodePoint.SYNTAXRM:
466             parseSYNTAXRM();
467             break;
468         case CodePoint.VALNSPRM:
469             parseVALNSPRM();
470             break;
471         default:
472             doObjnsprmSemantics(peekCP);
473         }
474     }
475     
476     /**
477      * Perform necessary actions for parsing of a ABNUOWRM message.
478      *
479      * @param connection an implementation of the ConnectionCallbackInterface
480      *
481      * @return an NetSqlca object obtained from parsing the ABNUOWRM
482      * @throws DisconnectException
483      *
484      */

485     NetSqlca parseAbnormalEndUow(ConnectionCallbackInterface connection,UnitOfWorkListener uwl) throws DisconnectException {
486         parseABNUOWRM();
487         if (peekCodePoint() != CodePoint.SQLCARD) {
488             parseTypdefsOrMgrlvlovrs();
489         }
490
491         NetSqlca netSqlca = parseSQLCARD(null);
492         
493         if(ExceptionUtil.getSeverityFromIdentifier(netSqlca.getSqlState()) >
494             ExceptionSeverity.STATEMENT_SEVERITY || uwl == null)
495             connection.completeAbnormalUnitOfWork();
496         else
497             connection.completeAbnormalUnitOfWork(uwl);
498         
499         return netSqlca;
500     }
501     
502     /**
503      * Perform necessary actions for parsing of a ABNUOWRM message.
504      *
505      * @param s an implementation of the StatementCallbackInterface
506      *
507      * @return an NetSqlca object obtained from parsing the ABNUOWRM
508      * @throws DisconnectException
509      *
510      */

511     NetSqlca parseAbnormalEndUow(StatementCallbackInterface s) throws DisconnectException {
512         return parseAbnormalEndUow(s.getConnectionCallbackInterface(),s);
513     }
514     
515     /**
516      * Perform necessary actions for parsing of a ABNUOWRM message.
517      *
518      * @param r an implementation of the ResultsetCallbackInterface
519      *
520      * @return an NetSqlca object obtained from parsing the ABNUOWRM
521      * @throws DisconnectException
522      *
523      */

524     NetSqlca parseAbnormalEndUow(ResultSetCallbackInterface r) throws DisconnectException {
525         return parseAbnormalEndUow(r.getConnectionCallbackInterface(),r);
526     }
527
528     void parseRdbAccessFailed(NetConnection netConnection) throws DisconnectException {
529         parseRDBAFLRM();
530
531         // an SQLCARD is returned if an RDBALFRM is returned.
532
// this SQLCARD always follows the RDBALFRM.
533
// TYPDEFNAM and TYPDEFOVR are MTLINC
534

535         if (peekCodePoint() == CodePoint.TYPDEFNAM) {
536             parseTYPDEFNAM();
537             parseTYPDEFOVR();
538         } else {
539             parseTYPDEFOVR();
540             parseTYPDEFNAM();
541         }
542
543         NetSqlca netSqlca = parseSQLCARD(null);
544         
545         //Check if the SQLCARD has null SQLException
546
if(netSqlca.getSqlErrmc() == null)
547             netConnection.setConnectionNull(true);
548         else
549             netConnection.completeSqlca(netSqlca);
550     }
551
552
553     // The Security Check (SECCHKRM) Reply Message indicates the acceptability
554
// of the security information.
555
// this method returns the security check code. it is up to the caller to check
556
// the value of this return code and take the appropriate action.
557
//
558
// Returned from Server:
559
// SVRCOD - required (0 - INFO, 8 - ERROR, 16 -SEVERE)
560
// SECCHKCD - required
561
// SECTKN - optional, ignorable
562
// SVCERRNO - optional
563
private void parseSECCHKRM(NetConnection netConnection) throws DisconnectException {
564         boolean svrcodReceived = false;
565         int svrcod = CodePoint.SVRCOD_INFO;
566         boolean secchkcdReceived = false;
567         int secchkcd = CodePoint.SECCHKCD_00;
568         boolean sectknReceived = false;
569         byte[] sectkn = null;
570
571         parseLengthAndMatchCodePoint(CodePoint.SECCHKRM);
572         pushLengthOnCollectionStack();
573         int peekCP = peekCodePoint();
574
575         while (peekCP != Reply.END_OF_COLLECTION) {
576
577             boolean foundInPass = false;
578
579             if (peekCP == CodePoint.SVRCOD) {
580                 // severity code. it's value is dictated by the SECCHKCD.
581
// right now it will not be checked that it is the correct value
582
// for the SECCHKCD. maybe this will be done in the future.
583
foundInPass = true;
584                 svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
585                 svrcod = parseSVRCOD(CodePoint.SVRCOD_INFO, CodePoint.SVRCOD_SEVERE);
586                 peekCP = peekCodePoint();
587             }
588
589             if (peekCP == CodePoint.SECCHKCD) {
590                 // security check code. this specifies the state of the security information.
591
// there is a relationship between this value and the SVRCOD value.
592
// right now this driver will not check these values against each other.
593
foundInPass = true;
594                 secchkcdReceived = checkAndGetReceivedFlag(secchkcdReceived);
595                 secchkcd = parseSECCHKCD();
596                 peekCP = peekCodePoint();
597             }
598
599             if (peekCP == CodePoint.SECTKN) {
600                 // security token.
601
// used when mutual authentication of the source and target servers
602
// is requested. The architecture lists this as an instance variable
603
// and also says that the SECTKN flows as reply data to the secchk cmd and
604
// it must flow after the secchkrm message. Right now this driver doesn't
605
// support ay mutual authentication so it will be ignored (it is listed
606
// as an ignorable instance variable in the ddm manual).
607
foundInPass = true;
608                 sectknReceived = checkAndGetReceivedFlag(sectknReceived);
609                 sectkn = parseSECTKN(true);
610                 peekCP = peekCodePoint();
611             }
612
613             if (!foundInPass) {
614                 doPrmnsprmSemantics(peekCP);
615             }
616
617         }
618         popCollectionStack();
619         // check for the required instance variables.
620
checkRequiredObjects(svrcodReceived, secchkcdReceived);
621
622         netConnection.securityCheckComplete(svrcod, secchkcd);
623     }
624
625
626     // Access to RDB Completed (ACRDBRM) Reply Message specifies that an
627
// instance of the SQL application manager has been created and is bound
628
// to the specified relation database (RDB).
629
//
630
// Returned from Server:
631
// SVRCOD - required (0 - INFO, 4 - WARNING)
632
// PRDID - required
633
// TYPDEFNAM - required (MINLVL 4) (QTDSQLJVM)
634
// TYPDEFOVR - required
635
// RDBINTTKN - optional
636
// CRRTKN - optional
637
// USRID - optional
638
// SRVLST - optional (MINLVL 5)
639
private void parseACCRDBRM(NetConnection netConnection) throws DisconnectException {
640         boolean svrcodReceived = false;
641         int svrcod = CodePoint.SVRCOD_INFO;
642         boolean prdidReceived = false;
643         String JavaDoc prdid = null;
644         boolean typdefnamReceived = false;
645         boolean typdefovrReceived = false;
646         boolean rdbinttknReceived = false;
647         boolean crrtknReceived = false;
648         byte[] crrtkn = null;
649         boolean usridReceived = false;
650         String JavaDoc usrid = null;
651
652         parseLengthAndMatchCodePoint(CodePoint.ACCRDBRM);
653         pushLengthOnCollectionStack();
654         int peekCP = peekCodePoint();
655
656         while (peekCP != Reply.END_OF_COLLECTION) {
657
658             boolean foundInPass = false;
659
660             if (peekCP == CodePoint.SVRCOD) {
661                 // severity code. If the target SQLAM cannot support the typdefovr
662
// parameter values specified for the double-byte and mixed-byte CCSIDs
663
// on the corresponding ACCRDB command, then the severity code WARNING
664
// is specified on the ACCRDBRM.
665
foundInPass = true;
666                 svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
667                 svrcod = parseSVRCOD(CodePoint.SVRCOD_INFO, CodePoint.SVRCOD_WARNING);
668                 peekCP = peekCodePoint();
669             }
670
671             // this is the product release level of the target RDB server.
672
if (peekCP == CodePoint.PRDID) {
673                 foundInPass = true;
674                 prdidReceived = checkAndGetReceivedFlag(prdidReceived);
675                 prdid = parsePRDID(false); // false means do not skip the bytes
676
peekCP = peekCodePoint();
677             }
678
679             if (peekCP == CodePoint.TYPDEFNAM) {
680                 // this is the name of the data type to the data representation mapping
681
// definitions tha the target SQLAM uses when sending reply data objects.
682
foundInPass = true;
683                 typdefnamReceived = checkAndGetReceivedFlag(typdefnamReceived);
684                 parseTYPDEFNAM();
685                 peekCP = peekCodePoint();
686             }
687
688             if (peekCP == CodePoint.TYPDEFOVR) {
689                 // this is the single-byte, double-byte, and mixed-byte CCSIDs of the
690
// scalar data arrays (SDA) in the identified data type to data representation
691
// mapping definitions.
692
foundInPass = true;
693                 typdefovrReceived = checkAndGetReceivedFlag(typdefovrReceived);
694                 parseTYPDEFOVR();
695                 peekCP = peekCodePoint();
696             }
697
698
699             if (peekCP == CodePoint.USRID) {
700                 // specifies the target defined user ID. It is returned if the value of
701
// TRGDFTRT is TRUE in ACCRDB. Right now this driver always sets this
702
// value to false so this should never get returned here.
703
// if it is returned, it could be considered an error but for now
704
// this driver will just skip the bytes.
705
foundInPass = true;
706                 usridReceived = checkAndGetReceivedFlag(usridReceived);
707                 usrid = parseUSRID(true);
708                 peekCP = peekCodePoint();
709             }
710
711             if (peekCP == CodePoint.CRRTKN) {
712                 // carries information to correlate with the work being done on bahalf
713
// of an application at the source and at the target server.
714
// defualt value is ''.
715
// this parameter is only retunred if an only if the CRRTKN parameter
716
// is not received on ACCRDB. We will rely on server to send us this
717
// in ACCRDBRM
718
foundInPass = true;
719                 crrtknReceived = checkAndGetReceivedFlag(crrtknReceived);
720                 crrtkn = parseCRRTKN(false);
721                 peekCP = peekCodePoint();
722             }
723
724
725             if (!foundInPass) {
726                 doPrmnsprmSemantics(peekCP);
727             }
728         }
729         popCollectionStack();
730         // check for the required instance variables.
731
checkRequiredObjects(svrcodReceived,
732                 prdidReceived,
733                 typdefnamReceived,
734                 typdefovrReceived);
735
736         netConnection.rdbAccessed(svrcod,
737                 prdid,
738                 crrtknReceived,
739                 crrtkn);
740     }
741
742
743     // The End Unit of Work Condition (ENDUOWRM) Reply Mesage specifies
744
// that the unit of work has ended as a result of the last command.
745
//
746
// Returned from Server:
747
// SVRCOD - required (4 WARNING)
748
// UOWDSP - required
749
// RDBNAM - optional
750
void parseENDUOWRM(ConnectionCallbackInterface connection) throws DisconnectException {
751         boolean svrcodReceived = false;
752         int svrcod = CodePoint.SVRCOD_INFO;
753         boolean uowdspReceived = false;
754         int uowdsp = 0;
755         boolean rdbnamReceived = false;
756         String JavaDoc rdbnam = null;
757
758         parseLengthAndMatchCodePoint(CodePoint.ENDUOWRM);
759         pushLengthOnCollectionStack();
760         int peekCP = peekCodePoint();
761
762         while (peekCP != Reply.END_OF_COLLECTION) {
763
764             boolean foundInPass = false;
765
766             if (peekCP == CodePoint.SVRCOD) {
767                 foundInPass = true;
768                 svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
769                 svrcod = parseSVRCOD(CodePoint.SVRCOD_WARNING, CodePoint.SVRCOD_WARNING);
770                 peekCP = peekCodePoint();
771             }
772
773             if (peekCP == CodePoint.UOWDSP) {
774                 foundInPass = true;
775                 uowdspReceived = checkAndGetReceivedFlag(uowdspReceived);
776                 uowdsp = parseUOWDSP();
777                 peekCP = peekCodePoint();
778             }
779
780             if (peekCP == CodePoint.RDBNAM) {
781                 foundInPass = true;
782                 rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
783                 rdbnam = parseRDBNAM(true);
784                 peekCP = peekCodePoint();
785             }
786
787
788             if (!foundInPass) {
789                 doPrmnsprmSemantics(peekCP);
790             }
791         }
792         popCollectionStack();
793         checkRequiredObjects(svrcodReceived, uowdspReceived);
794
795         netAgent_.setSvrcod(svrcod);
796         if (uowdsp == CodePoint.UOWDSP_COMMIT) {
797             connection.completeLocalCommit();
798         } else {
799             connection.completeLocalRollback();
800         }
801     }
802
803     // Command Check Reply Message indicates that the requested
804
// command encountered an unarchitected and implementation-specific
805
// condition for which there is no architected message. If the severity
806
// code value is ERROR or greater, the command has failed. The
807
// message can be accompanied by other messages that help to identify
808
// the specific condition.
809
// The CMDCHKRM should not be used as a general catch-all in place of
810
// product-defined messages when using product extensions to DDM.
811
// PROTOCOL architects the SQLSTATE value depending on SVRCOD
812
// SVRCOD 0 -> SQLSTATE is not returned
813
// SVRCOD 8 -> SQLSTATE of 58008 or 58009
814
// SVRCOD 16,32,64,128 -> SQLSTATE of 58009
815
//
816
// Messages
817
// SQLSTATE : 58009
818
// Execution failed due to a distribution protocol error that caused deallocation of the conversation.
819
// SQLCODE : -30020
820
// Execution failed because of a Distributed Protocol
821
// Error that will affect the successful execution of subsequent
822
// commands and SQL statements: Reason Code <reason-code>.
823
// Some possible reason codes include:
824
// 121C Indicates that the user is not authorized to perform the requested command.
825
// 1232 The command could not be completed because of a permanent error.
826
// In most cases, the server will be in the process of an abend.
827
// 220A The target server has received an invalid data description.
828
// If a user SQLDA is specified, ensure that the fields are
829
// initialized correctly. Also, ensure that the length does not
830
// exceed the maximum allowed length for the data type being used.
831
//
832
// The command or statement cannot be processed. The current
833
// transaction is rolled back and the application is disconnected
834
// from the remote database.
835
//
836
//
837
// Returned from Server:
838
// SVRCOD - required (0 - INFO, 4 - WARNING, 8 - ERROR, 16 - SEVERE,
839
// 32 - ACCDMG, 64 - PRMDMG, 128 - SESDMG))
840
// RDBNAM - optional (MINLVL 3)
841
// RECCNT - optional (MINVAL 0, MINLVL 3)
842
//
843
// Called by all the Reply classesCMDCHKRM
844
protected void parseCMDCHKRM() throws DisconnectException {
845         boolean svrcodReceived = false;
846         int svrcod = CodePoint.SVRCOD_INFO;
847         boolean rdbnamReceived = false;
848         String JavaDoc rdbnam = null;
849         parseLengthAndMatchCodePoint(CodePoint.CMDCHKRM);
850         pushLengthOnCollectionStack();
851         int peekCP = peekCodePoint();
852
853         while (peekCP != Reply.END_OF_COLLECTION) {
854
855             boolean foundInPass = false;
856
857             if (peekCP == CodePoint.SVRCOD) {
858                 foundInPass = true;
859                 svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
860                 svrcod = parseSVRCOD(CodePoint.SVRCOD_INFO, CodePoint.SVRCOD_SESDMG);
861                 peekCP = peekCodePoint();
862             }
863
864             if (peekCP == CodePoint.RDBNAM) {
865                 foundInPass = true;
866                 rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
867                 rdbnam = parseRDBNAM(true);
868                 peekCP = peekCodePoint();
869             }
870             // skip over the RECCNT since it can't be found in the DDM book.
871

872             if (peekCP == 0x115C) {
873                 foundInPass = true;
874                 parseLengthAndMatchCodePoint(0x115C);
875                 skipBytes();
876                 peekCP = peekCodePoint();
877             }
878
879             if (!foundInPass) {
880                 doPrmnsprmSemantics(peekCP);
881             }
882
883         }
884         popCollectionStack();
885         checkRequiredObjects(svrcodReceived);
886
887         netAgent_.setSvrcod(svrcod);
888         agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
889             new ClientMessageId(SQLState.DRDA_CONNECTION_TERMINATED),
890             msgutil_.getTextMessage(MessageId.CONN_DRDA_CMDCHKRM)));
891     }
892
893
894     // RDB Not Accessed Reply Message indicates that the access relational
895
// database command (ACCRDB) was not issued prior to a command
896
// requesting the RDB Services.
897
// PROTOCOL Architects an SQLSTATE of 58008 or 58009.
898
//
899
// Messages
900
// SQLSTATE : 58009
901
// Execution failed due to a distribution protocol error that caused deallocation of the conversation.
902
// SQLCODE : -30020
903
// Execution failed because of a Distributed Protocol
904
// Error that will affect the successful execution of subsequent
905
// commands and SQL statements: Reason Code <reason-code>.
906
// Some possible reason codes include:
907
// 121C Indicates that the user is not authorized to perform the requested command.
908
// 1232 The command could not be completed because of a permanent error.
909
// In most cases, the server will be in the process of an abend.
910
// 220A The target server has received an invalid data description.
911
// If a user SQLDA is specified, ensure that the fields are
912
// initialized correctly. Also, ensure that the length does not
913
// exceed the maximum allowed length for the data type being used.
914
//
915
// The command or statement cannot be processed. The current
916
// transaction is rolled back and the application is disconnected
917
// from the remote database.
918
//
919
//
920
// Returned from Server:
921
// SVRCOD - required (8 - ERROR)
922
// RDBNAM - required
923
//
924
// Called by all the NET*Reply classes.
925
void parseRDBNACRM() throws DisconnectException {
926         boolean svrcodReceived = false;
927         int svrcod = CodePoint.SVRCOD_INFO;
928         boolean rdbnamReceived = false;
929         String JavaDoc rdbnam = null;
930
931         parseLengthAndMatchCodePoint(CodePoint.RDBNACRM);
932         pushLengthOnCollectionStack();
933         int peekCP = peekCodePoint();
934
935         while (peekCP != Reply.END_OF_COLLECTION) {
936
937             boolean foundInPass = false;
938
939             if (peekCP == CodePoint.SVRCOD) {
940                 foundInPass = true;
941                 svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
942                 svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
943                 peekCP = peekCodePoint();
944             }
945
946             if (peekCP == CodePoint.RDBNAM) {
947                 foundInPass = true;
948                 rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
949                 rdbnam = parseRDBNAM(true);
950                 peekCP = peekCodePoint();
951             }
952
953             if (!foundInPass) {
954                 doPrmnsprmSemantics(peekCP);
955             }
956
957         }
958         popCollectionStack();
959         checkRequiredObjects(svrcodReceived, rdbnamReceived);
960
961         netAgent_.setSvrcod(svrcod);
962         agent_.accumulateChainBreakingReadExceptionAndThrow(
963             new DisconnectException(agent_,
964                 new ClientMessageId(SQLState.DRDA_CONNECTION_TERMINATED),
965                 msgutil_.getTextMessage(MessageId.CONN_DRDA_RDBNACRM)));
966     }
967
968     // RDB Not Found Reply Message indicates that the target
969
// server cannot find the specified relational database.
970
// PROTOCOL architects an SQLSTATE of 08004.
971
//
972
// Messages
973
// SQLSTATE : 8004
974
// The application server rejected establishment of the connection.
975
// SQLCODE : -30061
976
// The database alias or database name <name> was not found at the remote node.
977
// The statement cannot be processed.
978
//
979
//
980
// Returned from Server:
981
// SVRCOD - required (8 - ERROR)
982
// RDBNAM - required
983
//
984
private void parseRDBNFNRM(NetConnection netConnection) throws DisconnectException {
985         boolean svrcodReceived = false;
986         int svrcod = CodePoint.SVRCOD_INFO;
987         boolean rdbnamReceived = false;
988         String JavaDoc rdbnam = null;
989
990         parseLengthAndMatchCodePoint(CodePoint.RDBNFNRM);
991         pushLengthOnCollectionStack();
992         int peekCP = peekCodePoint();
993
994         while (peekCP != Reply.END_OF_COLLECTION) {
995
996             boolean foundInPass = false;
997
998             if (peekCP == CodePoint.SVRCOD) {
999                 foundInPass = true;
1000                svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
1001                svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
1002                peekCP = peekCodePoint();
1003            }
1004
1005            if (peekCP == CodePoint.RDBNAM) {
1006                foundInPass = true;
1007                rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
1008                rdbnam = parseRDBNAM(true);
1009                peekCP = peekCodePoint();
1010            }
1011
1012
1013            if (!foundInPass) {
1014                doPrmnsprmSemantics(peekCP);
1015            }
1016
1017        }
1018        popCollectionStack();
1019        checkRequiredObjects(svrcodReceived, rdbnamReceived);
1020
1021        netAgent_.setSvrcod(svrcod);
1022        agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
1023            new ClientMessageId(SQLState.NET_DATABASE_NOT_FOUND),
1024            netConnection.databaseName_));
1025    }
1026
1027
1028    // Not Authorized to RDB Reply Message specifies that
1029
// the requester is not authorized to access the specified
1030
// relational database.
1031
// PROTOCOL architects an SQLSTATE of 08004
1032
//
1033
// Messages
1034
// SQLSTATE : 8004
1035
// Authorization ID <authorization-ID> attempted to perform the specified
1036
// <operation> without having been granted the proper authorization to do so.
1037
// SQLCODE : -30060
1038
// <authorization-ID> does not have the privilege to perform operation <operation>.
1039
//
1040
//
1041
// Returned from Server:
1042
// SVRCOD - required (8 - ERROR)
1043
// RDBNAM - required
1044
//
1045
private void parseRDBATHRM(NetConnection netConnection) throws DisconnectException {
1046        boolean svrcodReceived = false;
1047        int svrcod = CodePoint.SVRCOD_INFO;
1048        boolean rdbnamReceived = false;
1049        String JavaDoc rdbnam = null;
1050
1051        parseLengthAndMatchCodePoint(CodePoint.RDBATHRM);
1052        pushLengthOnCollectionStack();
1053        int peekCP = peekCodePoint();
1054
1055        while (peekCP != Reply.END_OF_COLLECTION) {
1056
1057            boolean foundInPass = false;
1058
1059            if (peekCP == CodePoint.SVRCOD) {
1060                foundInPass = true;
1061                svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
1062                svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
1063                peekCP = peekCodePoint();
1064            }
1065
1066            if (peekCP == CodePoint.RDBNAM) {
1067                foundInPass = true;
1068                rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
1069                rdbnam = parseRDBNAM(true);
1070                peekCP = peekCodePoint();
1071            }
1072
1073            if (!foundInPass) {
1074                doPrmnsprmSemantics(peekCP);
1075            }
1076
1077        }
1078        popCollectionStack();
1079        checkRequiredObjects(svrcodReceived, rdbnamReceived);
1080
1081        netAgent_.setSvrcod(svrcod);
1082        netAgent_.accumulateReadException(new SqlException(agent_.logWriter_,
1083            new ClientMessageId(SQLState.NET_CONNECT_AUTH_FAILED),
1084            msgutil_.getTextMessage(MessageId.CONN_USER_NOT_AUTHORIZED_TO_DB)));
1085    }
1086
1087    // Data Stream Syntax Error Reply Message indicates that the data
1088
// sent to the target agent does not structurally conform to the requirements
1089
// of the DDM architecture. The target agent terminated paring of the DSS
1090
// when the condition SYNERRCD specified was detected.
1091
// PROTOCOL architects an SQLSTATE of 58008 or 58009.
1092
//
1093
// Messages
1094
// SQLSTATE : 58009
1095
// Execution failed due to a distribution protocol error that caused deallocation of the conversation.
1096
// SQLCODE : -30020
1097
// Execution failed because of a Distributed Protocol
1098
// Error that will affect the successful execution of subsequent
1099
// commands and SQL statements: Reason Code <reason-code>.
1100
// Some possible reason codes include:
1101
// 121C Indicates that the user is not authorized to perform the requested command.
1102
// 1232 The command could not be completed because of a permanent error.
1103
// In most cases, the server will be in the process of an abend.
1104
// 220A The target server has received an invalid data description.
1105
// If a user SQLDA is specified, ensure that the fields are
1106
// initialized correctly. Also, ensure that the length does not
1107
// exceed the maximum allowed length for the data type being used.
1108
//
1109
// The command or statement cannot be processed. The current
1110
// transaction is rolled back and the application is disconnected
1111
// from the remote database.
1112
//
1113
//
1114
// Returned from Server:
1115
// SVRCOD - required (8 - ERROR)
1116
// SYNERRCD - required
1117
// RECCNT - optional (MINVAL 0, MINLVL 3) (will not be returned - should be ignored)
1118
// CODPNT - optional (MINLVL 3)
1119
// RDBNAM - optional (MINLVL 3)
1120
//
1121
protected void parseSYNTAXRM() throws DisconnectException {
1122        boolean svrcodReceived = false;
1123        int svrcod = CodePoint.SVRCOD_INFO;
1124        boolean synerrcdReceived = false;
1125        int synerrcd = 0;
1126        boolean rdbnamReceived = false;
1127        String JavaDoc rdbnam = null;
1128        boolean codpntReceived = false;
1129        int codpnt = 0;
1130
1131        parseLengthAndMatchCodePoint(CodePoint.SYNTAXRM);
1132        pushLengthOnCollectionStack();
1133        int peekCP = peekCodePoint();
1134
1135        while (peekCP != Reply.END_OF_COLLECTION) {
1136
1137            boolean foundInPass = false;
1138
1139            if (peekCP == CodePoint.SVRCOD) {
1140                foundInPass = true;
1141                svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
1142                svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
1143                peekCP = peekCodePoint();
1144            }
1145
1146            if (peekCP == CodePoint.SYNERRCD) {
1147                foundInPass = true;
1148                synerrcdReceived = checkAndGetReceivedFlag(synerrcdReceived);
1149                synerrcd = parseSYNERRCD();
1150                peekCP = peekCodePoint();
1151            }
1152
1153            if (peekCP == CodePoint.RDBNAM) {
1154                foundInPass = true;
1155                rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
1156                rdbnam = parseRDBNAM(true);
1157                peekCP = peekCodePoint();
1158            }
1159
1160            if (peekCP == CodePoint.CODPNT) {
1161                foundInPass = true;
1162                codpntReceived = checkAndGetReceivedFlag(codpntReceived);
1163                codpnt = parseCODPNT();
1164                peekCP = peekCodePoint();
1165            }
1166
1167            // RECCNT will be skipped.
1168

1169            if (!foundInPass) {
1170                doPrmnsprmSemantics(peekCP);
1171            }
1172        }
1173        popCollectionStack();
1174        checkRequiredObjects(svrcodReceived, synerrcdReceived);
1175
1176        netAgent_.setSvrcod(svrcod);
1177        doSyntaxrmSemantics(codpnt);
1178    }
1179
1180    // RDB Currently Accessed Reply Message inidcates that the
1181
// ACCRDB command cannot be issued because the requester
1182
// has access to a relational database.
1183
// PROTOCOL architects an SQLSTATE of 58008 or 58009.
1184
//
1185
// Messages
1186
// SQLSTATE : 58009
1187
// Execution failed due to a distribution protocol error that caused deallocation of the conversation.
1188
// SQLCODE : -30020
1189
// Execution failed because of a Distributed Protocol
1190
// Error that will affect the successful execution of subsequent
1191
// commands and SQL statements: Reason Code <reason-code>.
1192
// Some possible reason codes include:
1193
// 121C Indicates that the user is not authorized to perform the requested command.
1194
// 1232 The command could not be completed because of a permanent error.
1195
// In most cases, the server will be in the process of an abend.
1196
// 220A The target server has received an invalid data description.
1197
// If a user SQLDA is specified, ensure that the fields are
1198
// initialized correctly. Also, ensure that the length does not
1199
// exceed the maximum allowed length for the data type being used.
1200
//
1201
// The command or statement cannot be processed. The current
1202
// transaction is rolled back and the application is disconnected
1203
// from the remote database.
1204
//
1205
//
1206
// Returned from Server:
1207
// SVRCOD - required (8 - ERROR)
1208
// RDBNAM - required
1209
//
1210
private void parseRDBACCRM() throws DisconnectException {
1211        boolean svrcodReceived = false;
1212        int svrcod = CodePoint.SVRCOD_INFO;
1213        boolean rdbnamReceived = false;
1214        String JavaDoc rdbnam = null;
1215
1216        parseLengthAndMatchCodePoint(CodePoint.RDBACCRM);
1217        pushLengthOnCollectionStack();
1218        int peekCP = peekCodePoint();
1219
1220        while (peekCP != Reply.END_OF_COLLECTION) {
1221
1222            boolean foundInPass = false;
1223
1224            if (peekCP == CodePoint.SVRCOD) {
1225                foundInPass = true;
1226                svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
1227                svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
1228                peekCP = peekCodePoint();
1229            }
1230
1231            if (peekCP == CodePoint.RDBNAM) {
1232                foundInPass = true;
1233                rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
1234                rdbnam = parseRDBNAM(true);
1235                peekCP = peekCodePoint();
1236            }
1237
1238            if (!foundInPass) {
1239                doPrmnsprmSemantics(peekCP);
1240            }
1241
1242        }
1243        popCollectionStack();
1244        checkRequiredObjects(svrcodReceived, rdbnamReceived);
1245
1246        netAgent_.setSvrcod(svrcod);
1247        agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
1248            new ClientMessageId(SQLState.DRDA_CONNECTION_TERMINATED),
1249            msgutil_.getTextMessage(MessageId.CONN_DRDA_RDBACCRM)));
1250    }
1251
1252    // RDB Access Failed Reply Message specifies that the relational
1253
// database failed the attempted connection.
1254
// An SQLCARD object must also be returned, following the
1255
// RDBAFLRM, to explain why the RDB failed the connection.
1256
// In addition, the target SQLAM instance is destroyed.
1257
// The SQLSTATE is returned in the SQLCARD.
1258
//
1259
// Messages
1260
// SQLSTATE : 58009
1261
// Execution failed due to a distribution protocol error that caused deallocation of the conversation.
1262
// SQLCODE : -30020
1263
// Execution failed because of a Distributed Protocol
1264
// Error that will affect the successful execution of subsequent
1265
// commands and SQL statements: Reason Code <reason-code>.
1266
// Some possible reason codes include:
1267
// 121C Indicates that the user is not authorized to perform the requested command.
1268
// 1232 The command could not be completed because of a permanent error.
1269
// In most cases, the server will be in the process of an abend.
1270
// 220A The target server has received an invalid data description.
1271
// If a user SQLDA is specified, ensure that the fields are
1272
// initialized correctly. Also, ensure that the length does not
1273
// exceed the maximum allowed length for the data type being used.
1274
//
1275
// The command or statement cannot be processed. The current
1276
// transaction is rolled back and the application is disconnected
1277
// from the remote database.
1278
//
1279
//
1280
// Returned from Server:
1281
// SVRCOD - required (8 - ERROR)
1282
// RDBNAM - required
1283
//
1284
private void parseRDBAFLRM() throws DisconnectException {
1285        boolean svrcodReceived = false;
1286        int svrcod = CodePoint.SVRCOD_INFO;
1287        boolean rdbnamReceived = false;
1288        String JavaDoc rdbnam = null;
1289
1290        parseLengthAndMatchCodePoint(CodePoint.RDBAFLRM);
1291        pushLengthOnCollectionStack();
1292        int peekCP = peekCodePoint();
1293
1294        while (peekCP != Reply.END_OF_COLLECTION) {
1295
1296            boolean foundInPass = false;
1297
1298            if (peekCP == CodePoint.SVRCOD) {
1299                foundInPass = true;
1300                svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
1301                svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
1302                peekCP = peekCodePoint();
1303            }
1304
1305            if (peekCP == CodePoint.RDBNAM) {
1306                foundInPass = true;
1307                rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
1308                rdbnam = parseRDBNAM(true);
1309                peekCP = peekCodePoint();
1310            }
1311
1312            if (!foundInPass) {
1313                doPrmnsprmSemantics(peekCP);
1314            }
1315
1316        }
1317        popCollectionStack();
1318        checkRequiredObjects(svrcodReceived, rdbnamReceived);
1319
1320        netAgent_.setSvrcod(svrcod);
1321    }
1322
1323
1324    // Parameter Value Not Supported Reply Message indicates
1325
// that the parameter value specified is either not recognized
1326
// or not supported for the specified parameter.
1327
// The VALNSPRM can only be specified in accordance with
1328
// the rules specified for DDM subsetting.
1329
// The code point of the command parameter in error is
1330
// returned as a parameter in this message.
1331
// PROTOCOL Architects an SQLSTATE of 58017.
1332
//
1333
// if codepoint is 0x119C,0x119D, or 0x119E then SQLSTATE 58017, SQLCODE -332
1334
// else SQLSTATE 58017, SQLCODE -30073
1335
//
1336
// Messages
1337
// SQLSTATE : 58017
1338
// The DDM parameter value is not supported.
1339
// SQLCODE : -332
1340
// There is no available conversion for the source code page
1341
// <code page> to the target code page <code page>.
1342
// Reason code <reason-code>.
1343
// The reason codes are as follows:
1344
// 1 source and target code page combination is not supported
1345
// by the database manager.
1346
// 2 source and target code page combination is either not
1347
// supported by the database manager or by the operating
1348
// system character conversion utility on the client node.
1349
// 3 source and target code page combination is either not
1350
// supported by the database manager or by the operating
1351
// system character conversion utility on the server node.
1352
//
1353
// SQLSTATE : 58017
1354
// The DDM parameter value is not supported.
1355
// SQLCODE : -30073
1356
// <parameter-identifier> Parameter value <value> is not supported.
1357
// Some possible parameter identifiers include:
1358
// 002F The target server does not support the data type
1359
// requested by the application requester.
1360
// The target server does not support the CCSID
1361
// requested by the application requester. Ensure the CCSID
1362
// used by the requester is supported by the server.
1363
// 119C - Verify the single-byte CCSID.
1364
// 119D - Verify the double-byte CCSID.
1365
// 119E - Verify the mixed-byte CCSID.
1366
//
1367
// The current environment command or SQL statement
1368
// cannot be processed successfully, nor can any subsequent
1369
// commands or SQL statements. The current transaction is
1370
// rolled back and the application is disconnected
1371
// from the remote database. The command cannot be processed.
1372
//
1373
// Returned from Server:
1374
// SVRCOD - required (8 - ERROR)
1375
// CODPNT - required
1376
// RECCNT - optional (MINLVL 3, MINVAL 0) (will not be returned - should be ignored)
1377
// RDBNAM - optional (MINLVL 3)
1378
//
1379
protected void parseVALNSPRM() throws DisconnectException {
1380        boolean svrcodReceived = false;
1381        int svrcod = CodePoint.SVRCOD_INFO;
1382        boolean rdbnamReceived = false;
1383        String JavaDoc rdbnam = null;
1384        boolean codpntReceived = false;
1385        int codpnt = 0;
1386
1387        parseLengthAndMatchCodePoint(CodePoint.VALNSPRM);
1388        pushLengthOnCollectionStack();
1389        int peekCP = peekCodePoint();
1390
1391        while (peekCP != Reply.END_OF_COLLECTION) {
1392
1393            boolean foundInPass = false;
1394
1395            if (peekCP == CodePoint.SVRCOD) {
1396                foundInPass = true;
1397                svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
1398                svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
1399                peekCP = peekCodePoint();
1400            }
1401
1402            if (peekCP == CodePoint.RDBNAM) {
1403                foundInPass = true;
1404                rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
1405                rdbnam = parseRDBNAM(true);
1406                peekCP = peekCodePoint();
1407            }
1408
1409            if (peekCP == CodePoint.CODPNT) {
1410                foundInPass = true;
1411                codpntReceived = checkAndGetReceivedFlag(codpntReceived);
1412                codpnt = parseCODPNT();
1413                peekCP = peekCodePoint();
1414            }
1415
1416            // RECCNT will be skipped
1417

1418            if (!foundInPass) {
1419                doPrmnsprmSemantics(peekCP);
1420            }
1421
1422        }
1423        popCollectionStack();
1424        checkRequiredObjects(svrcodReceived, codpntReceived);
1425
1426        netAgent_.setSvrcod(svrcod);
1427        doValnsprmSemantics(codpnt, "\"\"");
1428    }
1429
1430
1431    // Conversational Protocol Error Reply Message
1432
// indicates that a conversational protocol error occurred.
1433
// PROTOCOL architects the SQLSTATE value depending on SVRCOD
1434
// SVRCOD 8 -> SQLSTATE of 58008 or 58009
1435
// SVRCOD 16,128 -> SQLSTATE of 58009
1436
//
1437
// Messages
1438
// SQLSTATE : 58009
1439
// Execution failed due to a distribution protocol error that caused deallocation of the conversation.
1440
// SQLCODE : -30020
1441
// Execution failed because of a Distributed Protocol
1442
// Error that will affect the successful execution of subsequent
1443
// commands and SQL statements: Reason Code <reason-code>.
1444
// Some possible reason codes include:
1445
// 121C Indicates that the user is not authorized to perform the requested command.
1446
// 1232 The command could not be completed because of a permanent error.
1447
// In most cases, the server will be in the process of an abend.
1448
// 220A The target server has received an invalid data description.
1449
// If a user SQLDA is specified, ensure that the fields are
1450
// initialized correctly. Also, ensure that the length does not
1451
// exceed the maximum allowed length for the data type being used.
1452
//
1453
// The command or statement cannot be processed. The current
1454
// transaction is rolled back and the application is disconnected
1455
// from the remote database.
1456
//
1457
//
1458
// Returned from Server:
1459
// SVRCOD - required (8 - ERROR, 16 - SEVERE, 128 - SESDMG)
1460
// PRCCNVCD - required
1461
// RECCNT - optional (MINVAL 0, MINLVL 3)
1462
// RDBNAM - optional (NINLVL 3)
1463
//
1464
protected void parsePRCCNVRM() throws DisconnectException {
1465        boolean svrcodReceived = false;
1466        int svrcod = CodePoint.SVRCOD_INFO;
1467        boolean rdbnamReceived = false;
1468        String JavaDoc rdbnam = null;
1469        boolean prccnvcdReceived = false;
1470        int prccnvcd = 0;
1471
1472        parseLengthAndMatchCodePoint(CodePoint.PRCCNVRM);
1473        pushLengthOnCollectionStack();
1474        int peekCP = peekCodePoint();
1475
1476        while (peekCP != Reply.END_OF_COLLECTION) {
1477
1478            boolean foundInPass = false;
1479
1480            if (peekCP == CodePoint.SVRCOD) {
1481                foundInPass = true;
1482                svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
1483                svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_SESDMG);
1484                peekCP = peekCodePoint();
1485            }
1486
1487            if (peekCP == CodePoint.RDBNAM) {
1488                foundInPass = true;
1489                rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
1490                rdbnam = parseRDBNAM(true);
1491                peekCP = peekCodePoint();
1492            }
1493
1494            if (peekCP == CodePoint.PRCCNVCD) {
1495                foundInPass = true;
1496                prccnvcdReceived = checkAndGetReceivedFlag(prccnvcdReceived);
1497                prccnvcd = parsePRCCNVCD();
1498                peekCP = peekCodePoint();
1499            }
1500
1501            if (!foundInPass) {
1502                doPrmnsprmSemantics(peekCP);
1503            }
1504
1505        }
1506        popCollectionStack();
1507        checkRequiredObjects(svrcodReceived, prccnvcdReceived);
1508
1509        netAgent_.setSvrcod(svrcod);
1510        doPrccnvrmSemantics(CodePoint.PRCCNVRM);
1511    }
1512
1513    // Object Not Supported Reply Message indicates that the target
1514
// server does not recognize or support the object
1515
// specified as data in an OBJDSS for the command associated
1516
// with the object.
1517
// The OBJNSPRM is also returned if an object is found in a
1518
// valid collection in an OBJDSS (such as RECAL collection)
1519
// that that is not valid for that collection.
1520
// PROTOCOL Architects an SQLSTATE of 58015.
1521
//
1522
// Messages
1523
// SQLSTATE : 58015
1524
// The DDM object is not supported.
1525
// SQLCODE : -30071
1526
// <object-identifier> Object is not supported.
1527
// The current transaction is rolled back and the application
1528
// is disconnected from the remote database. The command
1529
// cannot be processed.
1530
//
1531
//
1532
// Returned from Server:
1533
// SVRCOD - required (8 - ERROR, 16 - SEVERE)
1534
// CODPNT - required
1535
// RECCNT - optional (MINVAL 0) (will not be returned - should be ignored)
1536
// RDBNAM - optional (MINLVL 3)
1537
//
1538
// Also called by NetPackageReply and NetStatementReply
1539
void parseOBJNSPRM() throws DisconnectException {
1540        boolean svrcodReceived = false;
1541        int svrcod = CodePoint.SVRCOD_INFO;
1542        boolean rdbnamReceived = false;
1543        String JavaDoc rdbnam = null;
1544        boolean codpntReceived = false;
1545        int codpnt = 0;
1546
1547        parseLengthAndMatchCodePoint(CodePoint.OBJNSPRM);
1548        pushLengthOnCollectionStack();
1549        int peekCP = peekCodePoint();
1550
1551        while (peekCP != Reply.END_OF_COLLECTION) {
1552
1553            boolean foundInPass = false;
1554
1555            if (peekCP == CodePoint.SVRCOD) {
1556                foundInPass = true;
1557                svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
1558                svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_SEVERE);
1559                peekCP = peekCodePoint();
1560            }
1561
1562            if (peekCP == CodePoint.RDBNAM) {
1563                foundInPass = true;
1564                rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
1565                rdbnam = parseRDBNAM(true);
1566                peekCP = peekCodePoint();
1567            }
1568
1569            if (peekCP == CodePoint.CODPNT) {
1570                foundInPass = true;
1571                codpntReceived = checkAndGetReceivedFlag(codpntReceived);
1572                codpnt = parseCODPNT();
1573                peekCP = peekCodePoint();
1574            }
1575
1576            // skip the RECCNT
1577

1578            if (!foundInPass) {
1579                doPrmnsprmSemantics(peekCP);
1580            }
1581
1582        }
1583        popCollectionStack();
1584        checkRequiredObjects(svrcodReceived, codpntReceived);
1585
1586        netAgent_.setSvrcod(svrcod);
1587        doObjnsprmSemantics(codpnt);
1588    }
1589
1590
1591    // Manager-Level Conflict (MGRLVLRM) Reply Message indicates that
1592
// the manager levels specified in the MGRLVLLS conflict amoung
1593
// themselves or with previously specified manager levels.
1594
// - The manager-level dependencies of one specified manager violates another
1595
// specified maanger level.
1596
// - The manager- level specified attempts to respecify a manager level that
1597
// previously EXCSAT command specified.
1598
// PROTOCOL architects an SQLSTATE of 58010.
1599
//
1600
// Messages
1601
// SQLSTATE : 58010
1602
// Execution failed due to a distributed protocol error that will affect
1603
// the successful execution of subsequent DDM commands or SQL statements.
1604
// SQLCODE : -30021
1605
// Execution failed due to a distribution protocol error
1606
// that will affect the successful execution of subsequent
1607
// commands and SQL statements: Manager <manager> at Level <level>
1608
// not supported.
1609
//
1610
// A system error occurred that prevented successful connection
1611
// of the application to the remote database.
1612
//
1613
//
1614
// Returned from Server:
1615
// SVRCOD - required (8 - ERROR)
1616
// MGRLVLLS - required
1617
//
1618
private void parseMGRLVLRM() throws DisconnectException {
1619        boolean svrcodReceived = false;
1620        int svrcod = CodePoint.SVRCOD_INFO;
1621        boolean mgrlvllsReceived = false;
1622        int[] managerCodePoint = null;
1623        int[] managerLevel = null;
1624
1625        parseLengthAndMatchCodePoint(CodePoint.MGRLVLRM);
1626        pushLengthOnCollectionStack();
1627        int peekCP = peekCodePoint();
1628
1629        while (peekCP != Reply.END_OF_COLLECTION) {
1630
1631            boolean foundInPass = false;
1632
1633            if (peekCP == CodePoint.SVRCOD) {
1634                foundInPass = true;
1635                svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
1636                svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
1637                peekCP = peekCodePoint();
1638            }
1639
1640            if (peekCP == CodePoint.MGRLVLLS) {
1641                foundInPass = true;
1642                mgrlvllsReceived = checkAndGetReceivedFlag(mgrlvllsReceived);
1643
1644                parseLengthAndMatchCodePoint(CodePoint.MGRLVLLS);
1645                int managerListLength = getDdmLength();
1646                if ((managerListLength == 0) || ((managerListLength % 7) != 0)) {
1647                    doSyntaxrmSemantics(CodePoint.SYNERRCD_OBJ_LEN_NOT_ALLOWED);
1648                }
1649
1650                int managerCount = managerListLength / 7;
1651                managerCodePoint = new int[managerCount];
1652                managerLevel = new int[managerCount];
1653                for (int i = 0; i < managerCount; i++) {
1654                    managerCodePoint[i] = parseCODPNTDR();
1655                    managerLevel[i] = parseMGRLVLN();
1656                }
1657                peekCP = peekCodePoint();
1658            }
1659
1660
1661            if (!foundInPass) {
1662                doPrmnsprmSemantics(peekCP);
1663            }
1664
1665        }
1666        popCollectionStack();
1667        checkRequiredObjects(svrcodReceived, mgrlvllsReceived);
1668
1669        netAgent_.setSvrcod(svrcod);
1670        doMgrlvlrmSemantics(managerCodePoint, managerLevel);
1671    }
1672
1673
1674    // Command Not Supported Reply Message indicates that the specified
1675
// command is not recognized or not supported for the
1676
// specified target. The reply message can be returned
1677
// only in accordance with the architected rules for DDM subsetting.
1678
// PROTOCOL architects an SQLSTATE of 58014.
1679
//
1680
// Messages
1681
// SQLSTATE : 58014
1682
// The DDM command is not supported.
1683
// SQLCODE : -30070
1684
// <command-identifier> Command is not supported.
1685
// The current transaction is rolled back and the application is
1686
// disconnected from the remote database. The statement cannot be processed.
1687
//
1688
//
1689
// Returned from Server:
1690
// SVRCOD - required (4 - WARNING, 8 - ERROR) (MINLVL 2)
1691
// CODPNT - required
1692
// RDBNAM - optional (MINLVL 3)
1693
//
1694
protected void parseCMDNSPRM() throws DisconnectException {
1695        boolean svrcodReceived = false;
1696        int svrcod = CodePoint.SVRCOD_INFO;
1697        boolean rdbnamReceived = false;
1698        String JavaDoc rdbnam = null;
1699        boolean srvdgnReceived = false;
1700        byte[] srvdgn = null;
1701        boolean codpntReceived = false;
1702        int codpnt = 0;
1703
1704        parseLengthAndMatchCodePoint(CodePoint.CMDNSPRM);
1705        pushLengthOnCollectionStack();
1706        int peekCP = peekCodePoint();
1707
1708        while (peekCP != Reply.END_OF_COLLECTION) {
1709
1710            boolean foundInPass = false;
1711
1712            if (peekCP == CodePoint.SVRCOD) {
1713                foundInPass = true;
1714                svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
1715                svrcod = parseSVRCOD(CodePoint.SVRCOD_WARNING, CodePoint.SVRCOD_ERROR);
1716                peekCP = peekCodePoint();
1717            }
1718
1719            if (peekCP == CodePoint.RDBNAM) {
1720                foundInPass = true;
1721                rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
1722                rdbnam = parseRDBNAM(true);
1723                peekCP = peekCodePoint();
1724            }
1725
1726
1727            if (peekCP == CodePoint.CODPNT) {
1728                foundInPass = true;
1729                codpntReceived = checkAndGetReceivedFlag(codpntReceived);
1730                codpnt = parseCODPNT();
1731                peekCP = peekCodePoint();
1732            }
1733
1734            if (!foundInPass) {
1735                doPrmnsprmSemantics(peekCP);
1736            }
1737
1738        }
1739        popCollectionStack();
1740        checkRequiredObjects(svrcodReceived, codpntReceived);
1741
1742        netAgent_.setSvrcod(svrcod);
1743        agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
1744            new ClientMessageId(SQLState.DRDA_DDM_COMMAND_NOT_SUPPORTED),
1745                Integer.toHexString(codpnt)));
1746    }
1747
1748    // Abnormal End Unit of Work Condition Reply Message indicates
1749
// that the current unit of work ended abnormally because
1750
// of some action at the target server. This can be caused by a
1751
// deadlock resolution, operator intervention, or some similar
1752
// situation that caused the relational database to rollback
1753
// the current unit of work. This reply message is returned only
1754
// if an SQLAM issues the command. Whenever an ABNUOWRM is returned
1755
// in response to a command, an SQLCARD object must also be returned
1756
// following the ABNUOWRM. The SQLSTATE is returned in the SQLCARD.
1757
//
1758
// Returned from Server:
1759
// SVRCOD - required (8 - ERROR)
1760
// RDBNAM - required
1761
//
1762
// Called by all the NET*Reply classes.
1763
void parseABNUOWRM() throws DisconnectException {
1764        boolean svrcodReceived = false;
1765        int svrcod = CodePoint.SVRCOD_INFO;
1766        boolean rdbnamReceived = false;
1767        String JavaDoc rdbnam = null;
1768
1769        parseLengthAndMatchCodePoint(CodePoint.ABNUOWRM);
1770        pushLengthOnCollectionStack();
1771        int peekCP = peekCodePoint();
1772
1773        while (peekCP != Reply.END_OF_COLLECTION) {
1774
1775            boolean foundInPass = false;
1776
1777            if (peekCP == CodePoint.SVRCOD) {
1778                foundInPass = true;
1779                svrcodReceived = checkAndGetReceivedFlag(svrcodReceived);
1780                svrcod = parseSVRCOD(CodePoint.SVRCOD_ERROR, CodePoint.SVRCOD_ERROR);
1781                peekCP = peekCodePoint();
1782            }
1783
1784            if (peekCP == CodePoint.RDBNAM) {
1785                // skip the rbbnam since it doesn't tell us anything new.
1786
// there is no way to return it to the application anyway.
1787
// not having to convert this to a string is a time saver also.
1788
foundInPass = true;
1789                rdbnamReceived = checkAndGetReceivedFlag(rdbnamReceived);
1790                rdbnam = parseRDBNAM(true);
1791                peekCP = peekCodePoint();
1792            }
1793
1794            if (!foundInPass) {
1795                doPrmnsprmSemantics(peekCP);
1796            }
1797        }
1798
1799        popCollectionStack();
1800        checkRequiredObjects(svrcodReceived, rdbnamReceived);
1801
1802        // the abnuowrm has been received, do whatever state changes are necessary
1803
netAgent_.setSvrcod(svrcod);
1804    }
1805
1806    //--------------------- parse DDM Reply Data--------------------------------------
1807

1808    // The Server Attributes Reply Data (EXCSATRD) returns the following
1809
// information in response to an EXCSAT command:
1810
// - the target server's class name
1811
// - the target server's support level for each class of manager
1812
// the source requests
1813
// - the target server's product release level
1814
// - the target server's external name
1815
// - the target server's name
1816
//
1817
// Returned from Server:
1818
// EXTNAM - optional
1819
// MGRLVLLS - optional
1820
// SRVCLSNM - optional
1821
// SRVNAM - optional
1822
// SRVRLSLV - optional
1823
private void parseEXCSATRD(NetConnection netConnection) throws DisconnectException {
1824        boolean extnamReceived = false;
1825        String JavaDoc extnam = null;
1826        boolean mgrlvllsReceived = false;
1827        boolean srvclsnmReceived = false;
1828        String JavaDoc srvclsnm = null;
1829        boolean srvnamReceived = false;
1830        String JavaDoc srvnam = null;
1831        boolean srvrlslvReceived = false;
1832        String JavaDoc srvrlslv = null;
1833
1834        parseLengthAndMatchCodePoint(CodePoint.EXCSATRD);
1835        pushLengthOnCollectionStack();
1836        int peekCP = peekCodePoint();
1837
1838        while (peekCP != Reply.END_OF_COLLECTION) {
1839
1840            boolean foundInPass = false;
1841
1842            if (peekCP == CodePoint.EXTNAM) {
1843                // External Name is the name of the job, task, or process
1844
// on a system for which a DDM server is active. For a target
1845
// DDM server, the external name is the name of the job the system creates
1846
// or activates to run the DDM server.
1847
// No semantic meaning is assigned to external names in DDM.
1848
// External names are transmitted to aid in problem determination.
1849
// This driver will save the external name of the target (the
1850
// driver may use it for logging purposes later).
1851
foundInPass = true;
1852                extnamReceived = checkAndGetReceivedFlag(extnamReceived);
1853                extnam = parseEXTNAM();
1854                peekCP = peekCodePoint();
1855            }
1856
1857            if (peekCP == CodePoint.MGRLVLLS) {
1858                // Manager-Level List
1859
// specifies a list of code points and support levels for the
1860
// classes of managers a server supports
1861
foundInPass = true;
1862                mgrlvllsReceived = checkAndGetReceivedFlag(mgrlvllsReceived);
1863                parseMGRLVLLS(netConnection); // need to review this one, check input and output
1864
peekCP = peekCodePoint();
1865            }
1866
1867            if (peekCP == CodePoint.SRVCLSNM) {
1868                // Server Class Name
1869
// specifies the name of a class of ddm servers.
1870
foundInPass = true;
1871                srvclsnmReceived = checkAndGetReceivedFlag(srvclsnmReceived);
1872                srvclsnm = parseSRVCLSNM();
1873                peekCP = peekCodePoint();
1874            }
1875
1876            if (peekCP == CodePoint.SRVNAM) {
1877                // Server Name
1878
// no semantic meaning is assigned to server names in DDM,
1879
// it is recommended (by the DDM manual) that the server's
1880
// physical or logical location identifier be used as a server name.
1881
// server names are transmitted for problem determination purposes.
1882
// this driver will save this name and in the future may use it
1883
// for logging errors.
1884
foundInPass = true;
1885                srvnamReceived = checkAndGetReceivedFlag(srvnamReceived);
1886                srvnam = parseSRVNAM();
1887                peekCP = peekCodePoint();
1888            }
1889
1890            if (peekCP == CodePoint.SRVRLSLV) {
1891                // Server Product Release Level
1892
// specifies the procuct release level of a ddm server.
1893
// the contents are unarchitected.
1894
// this driver will save this information and in the future may
1895
// use it for logging purposes.
1896
foundInPass = true;
1897                srvrlslvReceived = checkAndGetReceivedFlag(srvrlslvReceived);
1898                srvrlslv = parseSRVRLSLV();
1899                peekCP = peekCodePoint();
1900            }
1901
1902            if (!foundInPass) {
1903                doPrmnsprmSemantics(peekCP);
1904            }
1905
1906        }
1907        popCollectionStack();
1908        // according the the DDM book, all these instance variables are optional
1909
netConnection.setServerAttributeData(extnam, srvclsnm, srvnam, srvrlslv);
1910    }
1911
1912    // Must make a version that does not change state in the associated connection
1913
private void parseDummyEXCSATRD(NetConnection netConnection) throws DisconnectException {
1914        boolean extnamReceived = false;
1915        String JavaDoc extnam = null;
1916        boolean mgrlvllsReceived = false;
1917        boolean srvclsnmReceived = false;
1918        String JavaDoc srvclsnm = null;
1919        boolean srvnamReceived = false;
1920        String JavaDoc srvnam = null;
1921        boolean srvrlslvReceived = false;
1922        String JavaDoc srvrlslv = null;
1923
1924        parseLengthAndMatchCodePoint(CodePoint.EXCSATRD);
1925        pushLengthOnCollectionStack();
1926        int peekCP = peekCodePoint();
1927
1928        while (peekCP != Reply.END_OF_COLLECTION) {
1929
1930            boolean foundInPass = false;
1931
1932            if (peekCP == CodePoint.EXTNAM) {
1933                // External Name is the name of the job, task, or process
1934
// on a system for which a DDM server is active. For a target
1935
// DDM server, the external name is the name of the job the system creates
1936
// or activates to run the DDM server.
1937
// No semantic meaning is assigned to external names in DDM.
1938
// External names are transmitted to aid in problem determination.
1939
// This driver will save the external name of the target (the
1940
// driver may use it for logging purposes later).
1941
foundInPass = true;
1942                extnamReceived = checkAndGetReceivedFlag(extnamReceived);
1943                extnam = parseEXTNAM();
1944                peekCP = peekCodePoint();
1945            }
1946
1947            if (peekCP == CodePoint.MGRLVLLS) {
1948                // Manager-Level List
1949
// specifies a list of code points and support levels for the
1950
// classes of managers a server supports
1951
foundInPass = true;
1952                mgrlvllsReceived = checkAndGetReceivedFlag(mgrlvllsReceived);
1953                parseMGRLVLLS(netConnection); // need to review this one, check input and output
1954
peekCP = peekCodePoint();
1955            }
1956
1957            if (peekCP == CodePoint.SRVCLSNM) {
1958                // Server Class Name
1959
// specifies the name of a class of ddm servers.
1960
foundInPass = true;
1961                srvclsnmReceived = checkAndGetReceivedFlag(srvclsnmReceived);
1962                srvclsnm = parseSRVCLSNM();
1963                peekCP = peekCodePoint();
1964            }
1965
1966            if (peekCP == CodePoint.SRVNAM) {
1967                // Server Name
1968
// no semantic meaning is assigned to server names in DDM,
1969
// it is recommended (by the DDM manual) that the server's
1970
// physical or logical location identifier be used as a server name.
1971
// server names are transmitted for problem determination purposes.
1972
// this driver will save this name and in the future may use it
1973
// for logging errors.
1974
foundInPass = true;
1975                srvnamReceived = checkAndGetReceivedFlag(srvnamReceived);
1976                srvnam = parseSRVNAM();
1977                peekCP = peekCodePoint();
1978            }
1979
1980            if (peekCP == CodePoint.SRVRLSLV) {
1981                // Server Product Release Level
1982
// specifies the procuct release level of a ddm server.
1983
// the contents are unarchitected.
1984
// this driver will save this information and in the future may
1985
// use it for logging purposes.
1986
foundInPass = true;
1987                srvrlslvReceived = checkAndGetReceivedFlag(srvrlslvReceived);
1988                srvrlslv = parseSRVRLSLV();
1989                peekCP = peekCodePoint();
1990            }
1991
1992            if (!foundInPass) {
1993                doPrmnsprmSemantics(peekCP);
1994            }
1995
1996        }
1997        popCollectionStack();
1998        // according the the DDM book, all these instance variables are optional
1999
// don't change state of netConnection because this is a DUMMY flow
2000
//netConnection.setServerAttributeData (extnam, srvclsnm, srvnam, srvrlslv);
2001
}
2002
2003    // The Access Security Reply Data (ACSECRD) Collection Object contains
2004
// the security information from a target server's security manager.
2005
// this method returns the security check code received from the server
2006
// (if the server does not return a security check code, this method
2007
// will return 0). it is up to the caller to check
2008
// the value of this return code and take the appropriate action.
2009
//
2010
// Returned from Server:
2011
// SECMEC - required
2012
// SECTKN - optional (MINLVL 6)
2013
// SECCHKCD - optional
2014
private void parseACCSECRD(NetConnection netConnection, int securityMechanism) throws DisconnectException {
2015        boolean secmecReceived = false;
2016        int[] secmecList = null;
2017        boolean sectknReceived = false;
2018        byte[] sectkn = null;
2019        boolean secchkcdReceived = false;
2020        int secchkcd = 0;
2021
2022        parseLengthAndMatchCodePoint(CodePoint.ACCSECRD);
2023        pushLengthOnCollectionStack();
2024        int peekCP = peekCodePoint();
2025
2026        while (peekCP != Reply.END_OF_COLLECTION) {
2027
2028            boolean foundInPass = false;
2029
2030            if (peekCP == CodePoint.SECMEC) {
2031                // security mechanism.
2032
// this value must either reflect the value sent in the ACCSEC command
2033
// if the target server supports it; or the values the target server
2034
// does support when it does not support or accept the value
2035
// requested by the source server.
2036
// the secmecs returned are treated as a list and stored in
2037
// targetSecmec_List.
2038
// if the target server supports the source's secmec, it
2039
// will be saved in the variable targetSecmec_ (NOTE: so
2040
// after calling this method, if targetSecmec_'s value is zero,
2041
// then the target did NOT support the source secmec. any alternate
2042
// secmecs would be contained in targetSecmec_List).
2043
foundInPass = true;
2044                secmecReceived = checkAndGetReceivedFlag(secmecReceived);
2045                secmecList = parseSECMEC();
2046                peekCP = peekCodePoint();
2047            }
2048
2049            if (peekCP == CodePoint.SECTKN) {
2050                // security token
2051
foundInPass = true;
2052                sectknReceived = checkAndGetReceivedFlag(sectknReceived);
2053                sectkn = parseSECTKN(false);
2054                peekCP = peekCodePoint();
2055            }
2056
2057            if (peekCP == CodePoint.SECCHKCD) {
2058                // security check code.
2059
// included if and only if an error is detected when processing
2060
// the ACCSEC command. this has an implied severity code
2061
// of ERROR.
2062
foundInPass = true;
2063                secchkcdReceived = checkAndGetReceivedFlag(secchkcdReceived);
2064                secchkcd = parseSECCHKCD();
2065                peekCP = peekCodePoint();
2066            }
2067
2068            if (!foundInPass) {
2069                doPrmnsprmSemantics(peekCP);
2070            }
2071        }
2072        popCollectionStack();
2073        checkRequiredObjects(secmecReceived);
2074
2075        netConnection.setAccessSecurityData(secchkcd,
2076                securityMechanism,
2077                secmecList,
2078                sectknReceived,
2079                sectkn);
2080    }
2081
2082    // Called by all the NET*Reply classes.
2083
void parseTYPDEFNAM() throws DisconnectException {
2084        parseLengthAndMatchCodePoint(CodePoint.TYPDEFNAM);
2085        netAgent_.targetTypdef_.setTypdefnam(readString());
2086    }
2087
2088    // Called by all the NET*Reply classes.
2089
void parseTYPDEFOVR() throws DisconnectException {
2090        parseLengthAndMatchCodePoint(CodePoint.TYPDEFOVR);
2091        pushLengthOnCollectionStack();
2092        int peekCP = peekCodePoint();
2093
2094        while (peekCP != Reply.END_OF_COLLECTION) {
2095
2096            boolean foundInPass = false;
2097
2098            if (peekCP == CodePoint.CCSIDSBC) {
2099                foundInPass = true;
2100                netAgent_.targetTypdef_.setCcsidSbc(parseCCSIDSBC());
2101                peekCP = peekCodePoint();
2102            }
2103
2104            if (peekCP == CodePoint.CCSIDDBC) {
2105                foundInPass = true;
2106                netAgent_.targetTypdef_.setCcsidDbc(parseCCSIDDBC());
2107                peekCP = peekCodePoint();
2108            }
2109
2110            if (peekCP == CodePoint.CCSIDMBC) {
2111                foundInPass = true;
2112                netAgent_.targetTypdef_.setCcsidMbc(parseCCSIDMBC());
2113                peekCP = peekCodePoint();
2114            }
2115
2116            if (!foundInPass) {
2117                doPrmnsprmSemantics(peekCP);
2118            }
2119
2120        }
2121        popCollectionStack();
2122    }
2123
2124
2125    // The SYNCCRD Reply Mesage
2126
//
2127
// Returned from Server:
2128
// XARETVAL - required
2129
int parseSYNCCRD(ConnectionCallbackInterface connection) throws DisconnectException {
2130        return 0;
2131    }
2132
2133    // Process XA return value
2134
protected int parseXARETVAL() throws DisconnectException {
2135        return 0;
2136    }
2137
2138    // Process XA return value
2139
protected byte parseSYNCTYPE() throws DisconnectException {
2140        return 0;
2141    }
2142
2143    // This method handles the parsing of all command replies and reply data
2144
// for the SYNCCTL command.
2145
protected int parseSYNCCTLreply(ConnectionCallbackInterface connection) throws DisconnectException {
2146        return 0;
2147    }
2148
2149    // Called by the XA commit and rollback parse reply methods.
2150
void parseSYNCCTLError(int peekCP) throws DisconnectException {
2151        switch (peekCP) {
2152        case CodePoint.CMDCHKRM:
2153            parseCMDCHKRM();
2154            break;
2155        case CodePoint.PRCCNVRM:
2156            parsePRCCNVRM();
2157            break;
2158        case CodePoint.SYNTAXRM:
2159            parseSYNTAXRM();
2160            break;
2161        case CodePoint.VALNSPRM:
2162            parseVALNSPRM();
2163            break;
2164        default:
2165            doObjnsprmSemantics(peekCP);
2166        }
2167    }
2168
2169
2170    // Manager-Level List.
2171
// Specifies a list of code points and support levels for the
2172
// classes of managers a server supports.
2173
// The target server must not provide information for any target
2174
// managers unless the source explicitly requests it.
2175
// For each manager class, if the target server's support level
2176
// is greater than or equal to the source server's level, then the source
2177
// server's level is returned for that class if the target server can operate
2178
// at the source's level; otherwise a level 0 is returned. If the target
2179
// server's support level is less than the source server's level, the
2180
// target server's level is returned for that class. If the target server
2181
// does not recognize the code point of a manager class or does not support
2182
// that class, it returns a level of 0. The target server then waits
2183
// for the next command or for the source server to terminate communications.
2184
// When the source server receives EXCSATRD, it must compare each of the entries
2185
// in the mgrlvlls parameter it received to the corresponding entries in the mgrlvlls
2186
// parameter it sent. If any level mismatches, the source server must decide
2187
// whether it can use or adjust to the lower level of target support for that manager
2188
// class. There are no architectural criteria for making this decision.
2189
// The source server can terminate communications or continue at the target
2190
// servers level of support. It can also attempt to use whatever
2191
// commands its user requests while receiving eror reply messages for real
2192
// functional mismatches.
2193
// The manager levels the source server specifies or the target server
2194
// returns must be compatible with the manager-level dependencies of the specified
2195
// manangers. Incompatible manager levels cannot be specified.
2196
// After this method successfully returns, the targetXXXX values (where XXXX
2197
// represents a manager name. example targetAgent) contain the negotiated
2198
// manager levels for this particular connection.
2199
private void parseMGRLVLLS(NetConnection netConnection) throws DisconnectException {
2200        parseLengthAndMatchCodePoint(CodePoint.MGRLVLLS);
2201
2202        // each manager class and level is 4 bytes long.
2203
// get the length of the mgrlvls bytes, make sure it contains
2204
// the correct number of bytes for a mgrlvlls object, and calculate
2205
// the number of manager's returned from the server.
2206
int managerListLength = getDdmLength();
2207        if ((managerListLength == 0) || ((managerListLength % 4) != 0)) {
2208            doSyntaxrmSemantics(CodePoint.SYNERRCD_OBJ_LEN_NOT_ALLOWED);
2209        }
2210        int managerCount = managerListLength / 4;
2211
2212        // the managerCount should be equal to the same number of
2213
// managers sent on the excsat.
2214

2215        // read each of the manager levels returned from the server.
2216
for (int i = 0; i < managerCount; i++) {
2217
2218            // first two byte are the manager's codepoint, next two bytes are the level.
2219
int managerCodePoint = parseCODPNTDR();
2220            int managerLevel = parseMGRLVLN();
2221
2222            // check each manager to make sure levels are within proper limits
2223
// for this driver. Also make sure unexpected managers are not returned.
2224
switch (managerCodePoint) {
2225
2226            case CodePoint.AGENT:
2227                if ((managerLevel < NetConfiguration.MIN_AGENT_MGRLVL) ||
2228                        (managerLevel > netConnection.targetAgent_)) {
2229                    doMgrlvlrmSemantics(managerCodePoint, managerLevel);
2230                }
2231                netConnection.targetAgent_ = managerLevel;
2232                break;
2233
2234            case CodePoint.CMNTCPIP:
2235                if ((managerLevel < NetConfiguration.MIN_CMNTCPIP_MGRLVL) ||
2236                        (managerLevel > netConnection.targetCmntcpip_)) {
2237                    doMgrlvlrmSemantics(managerCodePoint, managerLevel);
2238                }
2239                netConnection.targetCmntcpip_ = managerLevel;
2240                break;
2241
2242            case CodePoint.RDB:
2243                if ((managerLevel < NetConfiguration.MIN_RDB_MGRLVL) ||
2244                        (managerLevel > netConnection.targetRdb_)) {
2245                    doMgrlvlrmSemantics(managerCodePoint, managerLevel);
2246                }
2247                netConnection.targetRdb_ = managerLevel;
2248                break;
2249
2250            case CodePoint.SECMGR:
2251                if ((managerLevel < NetConfiguration.MIN_SECMGR_MGRLVL) ||
2252                        (managerLevel > netConnection.targetSecmgr_)) {
2253                    doMgrlvlrmSemantics(managerCodePoint, managerLevel);
2254                }
2255                netConnection.targetSecmgr_ = managerLevel;
2256                break;
2257
2258            case CodePoint.SQLAM:
2259                if ((managerLevel < NetConfiguration.MIN_SQLAM_MGRLVL) ||
2260                        (managerLevel > netAgent_.targetSqlam_)) {
2261                    doMgrlvlrmSemantics(managerCodePoint, managerLevel);
2262                }
2263                netAgent_.orignalTargetSqlam_ = managerLevel;
2264                break;
2265
2266            case CodePoint.CMNAPPC:
2267                if ((managerLevel < NetConfiguration.MIN_CMNAPPC_MGRLVL) ||
2268                        (managerLevel > netConnection.targetCmnappc_)) {
2269                    doMgrlvlrmSemantics(managerCodePoint, managerLevel);
2270                }
2271                netConnection.targetCmnappc_ = managerLevel;
2272                break;
2273
2274            case CodePoint.XAMGR:
2275                if ((managerLevel != 0) &&
2276                        (managerLevel < NetConfiguration.MIN_XAMGR_MGRLVL) ||
2277                        (managerLevel > netConnection.targetXamgr_)) {
2278                    doMgrlvlrmSemantics(managerCodePoint, managerLevel);
2279                }
2280                netConnection.targetXamgr_ = managerLevel;
2281                break;
2282
2283            case CodePoint.SYNCPTMGR:
2284                if ((managerLevel != 0) &&
2285                        (managerLevel < NetConfiguration.MIN_SYNCPTMGR_MGRLVL) ||
2286                        (managerLevel > netConnection.targetSyncptmgr_)) {
2287                    doMgrlvlrmSemantics(managerCodePoint, managerLevel);
2288                }
2289                netConnection.targetSyncptmgr_ = managerLevel;
2290                break;
2291
2292            case CodePoint.RSYNCMGR:
2293                if ((managerLevel != 0) &&
2294                        (managerLevel < NetConfiguration.MIN_RSYNCMGR_MGRLVL) ||
2295                        (managerLevel > netConnection.targetRsyncmgr_)) {
2296                    doMgrlvlrmSemantics(managerCodePoint, managerLevel);
2297                }
2298                netConnection.targetRsyncmgr_ = managerLevel;
2299                break;
2300                // The target server must not provide information for any target managers
2301
// unless the source explicitly requests. The following managers are never requested.
2302
default:
2303                doMgrlvlrmSemantics(managerCodePoint, managerLevel);
2304                break;
2305            }
2306        }
2307    }
2308
2309    // The External Name is the name of the job, task, or process on a
2310
// system for which a DDM server is active. On a source DDM server,
2311
// the external name is the name of the job that is requesting
2312
// access to remote resources. For a target DDM server,
2313
// the external name is the name of the job the system
2314
// creates or activates to run the DDM server.
2315
// No semantic meaning is assigned to external names in DDM.
2316
// External names are transmitted to aid in problem determination.
2317
protected String JavaDoc parseEXTNAM() throws DisconnectException {
2318        parseLengthAndMatchCodePoint(CodePoint.EXTNAM);
2319        return readString();
2320    }
2321
2322    // Server Class name specifies the name of a class of DDM servers.
2323
// Server class names are assigned for each product involved in PROTOCOL.
2324
protected String JavaDoc parseSRVCLSNM() throws DisconnectException {
2325        parseLengthAndMatchCodePoint(CodePoint.SRVCLSNM);
2326        return readString();
2327    }
2328
2329    // Server Name is the name of the DDM server.
2330
// No semantic meaning is assigned to server names in DDM,
2331
// but it is recommended that the server names are transmitted
2332
// for problem determination.
2333
protected String JavaDoc parseSRVNAM() throws DisconnectException {
2334        parseLengthAndMatchCodePoint(CodePoint.SRVNAM);
2335        return readString();
2336    }
2337
2338    // Server Product Release Level String specifies the product
2339
// release level of a DDM server. The contents of the
2340
// parameter are unarchitected. Up to 255 bytes can be sent.
2341
// SRVRLSLV should not be used in place of product-defined
2342
// extensions to carry information not related to the products
2343
// release level.
2344
protected String JavaDoc parseSRVRLSLV() throws DisconnectException {
2345        parseLengthAndMatchCodePoint(CodePoint.SRVRLSLV);
2346        return readString();
2347    }
2348
2349    // Manager-Level Number Attribute Binary Integer Number specifies
2350
// the level of a defined DDM manager.
2351
protected int parseMGRLVLN() throws DisconnectException {
2352        return readUnsignedShort();
2353    }
2354
2355    // Security Mechanims.
2356
protected int[] parseSECMEC() throws DisconnectException {
2357        parseLengthAndMatchCodePoint(CodePoint.SECMEC);
2358        return readUnsignedShortList();
2359    }
2360
2361    // The Security Token Byte String is information provided and used
2362
// by the various security mechanisms.
2363
protected byte[] parseSECTKN(boolean skip) throws DisconnectException {
2364        parseLengthAndMatchCodePoint(CodePoint.SECTKN);
2365        if (skip) {
2366            skipBytes();
2367            return null;
2368        }
2369        return readBytes();
2370    }
2371
2372
2373    // The Security Check Code String codifies the security information
2374
// and condition for the SECCHKRM.
2375
protected int parseSECCHKCD() throws DisconnectException {
2376        parseLengthAndMatchCodePoint(CodePoint.SECCHKCD);
2377        int secchkcd = readUnsignedByte();
2378        if ((secchkcd < CodePoint.SECCHKCD_00) || (secchkcd > CodePoint.SECCHKCD_15)) {
2379            doValnsprmSemantics(CodePoint.SECCHKCD, secchkcd);
2380        }
2381        return secchkcd;
2382    }
2383
2384    // Product specific Identifier specifies the product release level
2385
// of a DDM server.
2386
protected String JavaDoc parsePRDID(boolean skip) throws DisconnectException {
2387        parseLengthAndMatchCodePoint(CodePoint.PRDID);
2388        if (skip) {
2389            skipBytes();
2390            return null;
2391        } else {
2392            return readString();
2393        }
2394    }
2395
2396    // The User Id specifies an end-user name.
2397
protected String JavaDoc parseUSRID(boolean skip) throws DisconnectException {
2398        parseLengthAndMatchCodePoint(CodePoint.USRID);
2399        if (skip) {
2400            skipBytes();
2401            return null;
2402        }
2403        return readString();
2404    };
2405
2406    // Code Point Data Representation specifies the data representation
2407
// of a dictionary codepoint. Code points are hexadecimal aliases for DDM
2408
// named terms.
2409
protected int parseCODPNTDR() throws DisconnectException {
2410        return readUnsignedShort();
2411    }
2412
2413    // Correlation Token specifies a token that is conveyed between source
2414
// and target servers for correlating the processing between servers.
2415
protected byte[] parseCRRTKN(boolean skip) throws DisconnectException {
2416        parseLengthAndMatchCodePoint(CodePoint.CRRTKN);
2417        if (skip) {
2418            skipBytes();
2419            return null;
2420        }
2421        return readBytes();
2422    }
2423
2424    // Unit of Work Disposition Scalar Object specifies the disposition of the
2425
// last unit of work.
2426
protected int parseUOWDSP() throws DisconnectException {
2427        parseLengthAndMatchCodePoint(CodePoint.UOWDSP);
2428        int uowdsp = readUnsignedByte();
2429        if ((uowdsp != CodePoint.UOWDSP_COMMIT) && (uowdsp != CodePoint.UOWDSP_ROLLBACK)) {
2430            doValnsprmSemantics(CodePoint.UOWDSP, uowdsp);
2431        }
2432        return uowdsp;
2433    }
2434
2435
2436    // Relational Database Name specifies the name of a relational
2437
// database of the server. A server can have more than one RDB.
2438
protected String JavaDoc parseRDBNAM(boolean skip) throws DisconnectException {
2439        parseLengthAndMatchCodePoint(CodePoint.RDBNAM);
2440        if (skip) {
2441            skipBytes();
2442            return null;
2443        }
2444        return readString();
2445    };
2446
2447
2448
2449    protected int parseXIDCNT() throws DisconnectException {
2450        parseLengthAndMatchCodePoint(CodePoint.XIDCNT);
2451        return readUnsignedShort();
2452    }
2453
2454    protected Xid JavaDoc parseXID() throws DisconnectException {
2455        return null;
2456    }
2457
2458    protected java.util.Hashtable JavaDoc parseIndoubtList() throws DisconnectException {
2459        return null;
2460    }
2461
2462
2463    // Syntax Error Code String specifies the condition that caused termination
2464
// of data stream parsing.
2465
protected int parseSYNERRCD() throws DisconnectException {
2466        parseLengthAndMatchCodePoint(CodePoint.SYNERRCD);
2467        int synerrcd = readUnsignedByte();
2468        if ((synerrcd < 0x01) || (synerrcd > 0x1D)) {
2469            doValnsprmSemantics(CodePoint.SYNERRCD, synerrcd);
2470        }
2471        return synerrcd;
2472    }
2473
2474    // The Code Point Data specifies a scalar value that is an architected code point.
2475
protected int parseCODPNT() throws DisconnectException {
2476        parseLengthAndMatchCodePoint(CodePoint.CODPNT);
2477        return parseCODPNTDR();
2478    }
2479
2480    // Conversational Protocol Error Code specifies the condition
2481
// for which the PRCCNVRm was returned.
2482
protected int parsePRCCNVCD() throws DisconnectException {
2483        parseLengthAndMatchCodePoint(CodePoint.PRCCNVCD);
2484        int prccnvcd = readUnsignedByte();
2485        if ((prccnvcd != 0x01) && (prccnvcd != 0x02) && (prccnvcd != 0x03) &&
2486                (prccnvcd != 0x04) && (prccnvcd != 0x05) && (prccnvcd != 0x06) &&
2487                (prccnvcd != 0x10) && (prccnvcd != 0x11) && (prccnvcd != 0x12) &&
2488                (prccnvcd != 0x13) && (prccnvcd != 0x15)) {
2489            doValnsprmSemantics(CodePoint.PRCCNVCD, prccnvcd);
2490        }
2491        return prccnvcd;
2492    }
2493
2494    // CCSID for Single-Byte Characters specifies a coded character
2495
// set identifier for single-byte characters.
2496
protected int parseCCSIDSBC() throws DisconnectException {
2497        parseLengthAndMatchCodePoint(CodePoint.CCSIDSBC);
2498        return readUnsignedShort();
2499    }
2500
2501    // CCSID for Mixed-Byte Characters specifies a coded character
2502
// set identifier for mixed-byte characters.
2503
protected int parseCCSIDMBC() throws DisconnectException {
2504        parseLengthAndMatchCodePoint(CodePoint.CCSIDMBC);
2505        return readUnsignedShort();
2506    }
2507
2508    // CCSID for Double-Byte Characters specifies a coded character
2509
// set identifier for double-byte characters.
2510
protected int parseCCSIDDBC() throws DisconnectException {
2511        parseLengthAndMatchCodePoint(CodePoint.CCSIDDBC);
2512        return readUnsignedShort();
2513    }
2514
2515    // Severity Code is an indicator of the severity of a condition
2516
// detected during the execution of a command.
2517
protected int parseSVRCOD(int minSvrcod, int maxSvrcod) throws DisconnectException {
2518        parseLengthAndMatchCodePoint(CodePoint.SVRCOD);
2519
2520        int svrcod = readUnsignedShort();
2521        if ((svrcod != CodePoint.SVRCOD_INFO) &&
2522                (svrcod != CodePoint.SVRCOD_WARNING) &&
2523                (svrcod != CodePoint.SVRCOD_ERROR) &&
2524                (svrcod != CodePoint.SVRCOD_SEVERE) &&
2525                (svrcod != CodePoint.SVRCOD_ACCDMG) &&
2526                (svrcod != CodePoint.SVRCOD_PRMDMG) &&
2527                (svrcod != CodePoint.SVRCOD_SESDMG)) {
2528            doValnsprmSemantics(CodePoint.SVRCOD, svrcod);
2529        }
2530
2531        if (svrcod < minSvrcod || svrcod > maxSvrcod) {
2532            doValnsprmSemantics(CodePoint.SVRCOD, svrcod);
2533        }
2534
2535        return svrcod;
2536    }
2537
2538    protected int parseFastSVRCOD(int minSvrcod, int maxSvrcod) throws DisconnectException {
2539        matchCodePoint(CodePoint.SVRCOD);
2540
2541        int svrcod = readFastUnsignedShort();
2542        if ((svrcod != CodePoint.SVRCOD_INFO) &&
2543                (svrcod != CodePoint.SVRCOD_WARNING) &&
2544                (svrcod != CodePoint.SVRCOD_ERROR) &&
2545                (svrcod != CodePoint.SVRCOD_SEVERE) &&
2546                (svrcod != CodePoint.SVRCOD_ACCDMG) &&
2547                (svrcod != CodePoint.SVRCOD_PRMDMG) &&
2548                (svrcod != CodePoint.SVRCOD_SESDMG)) {
2549            doValnsprmSemantics(CodePoint.SVRCOD, svrcod);
2550        }
2551
2552        if (svrcod < minSvrcod || svrcod > maxSvrcod) {
2553            doValnsprmSemantics(CodePoint.SVRCOD, svrcod);
2554        }
2555
2556        return svrcod;
2557    }
2558
2559    protected NetSqlca parseSQLCARD(Sqlca[] rowsetSqlca) throws DisconnectException {
2560        parseLengthAndMatchCodePoint(CodePoint.SQLCARD);
2561        int ddmLength = getDdmLength();
2562        ensureBLayerDataInBuffer(ddmLength);
2563        NetSqlca netSqlca = parseSQLCARDrow(rowsetSqlca);
2564        adjustLengths(getDdmLength());
2565        return netSqlca;
2566    }
2567    //--------------------------parse FDOCA objects------------------------
2568

2569    // SQLCARD : FDOCA EARLY ROW
2570
// SQL Communications Area Row Description
2571
//
2572
// FORMAT FOR ALL SQLAM LEVELS
2573
// SQLCAGRP; GROUP LID 0x54; ELEMENT TAKEN 0(all); REP FACTOR 1
2574

2575    NetSqlca parseSQLCARDrow(Sqlca[] rowsetSqlca) throws DisconnectException {
2576        return parseSQLCAGRP(rowsetSqlca);
2577    }
2578
2579    // SQLNUMROW : FDOCA EARLY ROW
2580
// SQL Number of Elements Row Description
2581
//
2582
// FORMAT FOR SQLAM LEVELS
2583
// SQLNUMGRP; GROUP LID 0x58; ELEMENT TAKEN 0(all); REP FACTOR 1
2584
int parseSQLNUMROW() throws DisconnectException {
2585        return parseSQLNUMGRP();
2586    }
2587
2588    int parseFastSQLNUMROW() throws DisconnectException {
2589        return parseFastSQLNUMGRP();
2590    }
2591
2592    // SQLNUMGRP : FDOCA EARLY GROUP
2593
// SQL Number of Elements Group Description
2594
//
2595
// FORMAT FOR ALL SQLAM LEVELS
2596
// SQLNUM; PROTOCOL TYPE I2; ENVLID 0x04; Length Override 2
2597
private int parseSQLNUMGRP() throws DisconnectException {
2598        return readShort();
2599    }
2600
2601    private int parseFastSQLNUMGRP() throws DisconnectException {
2602        return readFastShort();
2603    }
2604
2605    // SQLCAGRP : FDOCA EARLY GROUP
2606
// SQL Communcations Area Group Description
2607
//
2608
// FORMAT FOR SQLAM <= 6
2609
// SQLCODE; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2610
// SQLSTATE; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 5
2611
// SQLERRPROC; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 8
2612
// SQLCAXGRP; PROTOCOL TYPE N-GDA; ENVLID 0x52; Length Override 0
2613
//
2614
// FORMAT FOR SQLAM >= 7
2615
// SQLCODE; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2616
// SQLSTATE; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 5
2617
// SQLERRPROC; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 8
2618
// SQLCAXGRP; PROTOCOL TYPE N-GDA; ENVLID 0x52; Length Override 0
2619
// SQLDIAGGRP; PROTOCOL TYPE N-GDA; ENVLID 0x56; Length Override 0
2620
private NetSqlca parseSQLCAGRP(Sqlca[] rowsetSqlca) throws DisconnectException {
2621        if (readFastUnsignedByte() == CodePoint.NULLDATA) {
2622            return null;
2623        }
2624
2625        int sqlcode = readFastInt();
2626        byte[] sqlstate = readFastBytes(5);
2627        byte[] sqlerrproc = readFastBytes(8);
2628        NetSqlca netSqlca = null;
2629        
2630        try
2631        {
2632            netSqlca = new NetSqlca(netAgent_.netConnection_,
2633                    sqlcode,
2634                    sqlstate,
2635                    sqlerrproc);
2636        }
2637        catch(SqlException sqle)
2638        {
2639            throw new DisconnectException(netAgent_,sqle);
2640        }
2641        parseSQLCAXGRP(netSqlca);
2642
2643        if (netAgent_.targetSqlam_ >= NetConfiguration.MGRLVL_7) {
2644            netSqlca.setRowsetRowCount(parseSQLDIAGGRP(rowsetSqlca));
2645        }
2646
2647        return netSqlca;
2648    }
2649
2650    // SQLCAXGRP : EARLY FDOCA GROUP
2651
// SQL Communications Area Exceptions Group Description
2652
//
2653
// FORMAT FOR SQLAM <= 6
2654
// SQLRDBNME; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 18
2655
// SQLERRD1; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2656
// SQLERRD2; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2657
// SQLERRD3; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2658
// SQLERRD4; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2659
// SQLERRD5; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2660
// SQLERRD6; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2661
// SQLWARN0; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2662
// SQLWARN1; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2663
// SQLWARN2; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2664
// SQLWARN3; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2665
// SQLWARN4; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2666
// SQLWARN5; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2667
// SQLWARN6; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2668
// SQLWARN7; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2669
// SQLWARN8; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2670
// SQLWARN9; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2671
// SQLWARNA; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2672
// SQLERRMSG_m; PROTOCOL TYPE VCM; ENVLID 0x3E; Length Override 70
2673
// SQLERRMSG_s; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 70
2674
//
2675
// FORMAT FOR SQLAM >= 7
2676
// SQLERRD1; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2677
// SQLERRD2; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2678
// SQLERRD3; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2679
// SQLERRD4; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2680
// SQLERRD5; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2681
// SQLERRD6; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2682
// SQLWARN0; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2683
// SQLWARN1; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2684
// SQLWARN2; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2685
// SQLWARN3; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2686
// SQLWARN4; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2687
// SQLWARN5; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2688
// SQLWARN6; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2689
// SQLWARN7; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2690
// SQLWARN8; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2691
// SQLWARN9; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2692
// SQLWARNA; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2693
// SQLRDBNAME; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
2694
// SQLERRMSG_m; PROTOCOL TYPE VCM; ENVLID 0x3E; Length Override 70
2695
// SQLERRMSG_s; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 70
2696
private void parseSQLCAXGRP(NetSqlca netSqlca) throws DisconnectException {
2697        if (readFastUnsignedByte() == CodePoint.NULLDATA) {
2698            netSqlca.setContainsSqlcax(false);
2699            return;
2700        }
2701
2702        if (netAgent_.targetSqlam_ < NetConfiguration.MGRLVL_7) {
2703            // skip over the rdbnam for now
2704
// SQLRDBNME; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 18
2705
skipFastBytes(18);
2706        }
2707        // SQLERRD1 to SQLERRD6; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
2708
int[] sqlerrd = new int[6];
2709        readFastIntArray(sqlerrd);
2710
2711        // SQLWARN0 to SQLWARNA; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
2712
byte[] sqlwarn = readFastBytes(11);
2713
2714        if (netAgent_.targetSqlam_ >= NetConfiguration.MGRLVL_7) {
2715            // skip over the rdbnam for now
2716
// SQLRDBNAME; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
2717
parseFastVCS();
2718        }
2719
2720
2721        int sqlerrmcCcsid = 0;
2722        byte[] sqlerrmc = readFastLDBytes();
2723        if (sqlerrmc != null) {
2724            sqlerrmcCcsid = netAgent_.targetTypdef_.getCcsidMbc();
2725            skipFastBytes(2);
2726        } else {
2727            sqlerrmc = readFastLDBytes();
2728            sqlerrmcCcsid = netAgent_.targetTypdef_.getCcsidSbc();
2729        }
2730
2731        netSqlca.setSqlerrd(sqlerrd);
2732        netSqlca.setSqlwarnBytes(sqlwarn);
2733        netSqlca.setSqlerrmcBytes(sqlerrmc, sqlerrmcCcsid); // sqlerrmc may be null
2734
}
2735
2736    // SQLDIAGGRP : FDOCA EARLY GROUP
2737
// SQL Diagnostics Group Description - Identity 0xD1
2738
// Nullable Group
2739
// SQLDIAGSTT; PROTOCOL TYPE N-GDA; ENVLID 0xD3; Length Override 0
2740
// SQLDIAGCN; DRFA TYPE N-RLO; ENVLID 0xF6; Length Override 0
2741
// SQLDIAGCI; PROTOCOL TYPE N-RLO; ENVLID 0xF5; Length Override 0
2742
private long parseSQLDIAGGRP(Sqlca[] rowsetSqlca) throws DisconnectException {
2743        if (readFastUnsignedByte() == CodePoint.NULLDATA) {
2744            return 0;
2745        }
2746
2747        long row_count = parseSQLDIAGSTT(rowsetSqlca);
2748        parseSQLDIAGCI(rowsetSqlca);
2749        parseSQLDIAGCN();
2750
2751        return row_count;
2752    }
2753
2754    // this is duplicated in parseColumnMetaData, but different
2755
// DAGroup under NETColumnMetaData requires a lot more stuffs including
2756
// precsion, scale and other stuffs
2757
protected String JavaDoc parseFastVCS() throws DisconnectException {
2758        // doublecheck what readString() does if the length is 0
2759
return readFastString(readFastUnsignedShort(),
2760                netAgent_.targetTypdef_.getCcsidSbcEncoding());
2761    }
2762    //----------------------non-parsing computational helper methods--------------
2763

2764    protected boolean checkAndGetReceivedFlag(boolean receivedFlag) throws DisconnectException {
2765        if (receivedFlag) {
2766            // this method will throw a disconnect exception if
2767
// the received flag is already true;
2768
doSyntaxrmSemantics(CodePoint.SYNERRCD_DUP_OBJ_PRESENT);
2769        }
2770        return true;
2771    }
2772
2773    protected void checkRequiredObjects(boolean receivedFlag) throws DisconnectException {
2774        if (!receivedFlag) {
2775            doSyntaxrmSemantics(CodePoint.SYNERRCD_REQ_OBJ_NOT_FOUND);
2776        }
2777    }
2778
2779    protected void checkRequiredObjects(boolean receivedFlag,
2780                                        boolean receivedFlag2) throws DisconnectException {
2781        if (!receivedFlag || !receivedFlag2) {
2782            doSyntaxrmSemantics(CodePoint.SYNERRCD_REQ_OBJ_NOT_FOUND);
2783        }
2784    }
2785
2786    protected void checkRequiredObjects(boolean receivedFlag,
2787                                        boolean receivedFlag2,
2788                                        boolean receivedFlag3) throws DisconnectException {
2789        if (!receivedFlag || !receivedFlag2 || !receivedFlag3) {
2790            doSyntaxrmSemantics(CodePoint.SYNERRCD_REQ_OBJ_NOT_FOUND);
2791        }
2792    }
2793
2794    protected void checkRequiredObjects(boolean receivedFlag,
2795                                        boolean receivedFlag2,
2796                                        boolean receivedFlag3,
2797                                        boolean receivedFlag4) throws DisconnectException {
2798        if (!receivedFlag || !receivedFlag2 || !receivedFlag3 || !receivedFlag4) {
2799            doSyntaxrmSemantics(CodePoint.SYNERRCD_REQ_OBJ_NOT_FOUND);
2800        }
2801    }
2802
2803    protected void checkRequiredObjects(boolean receivedFlag,
2804                                        boolean receivedFlag2,
2805                                        boolean receivedFlag3,
2806                                        boolean receivedFlag4,
2807                                        boolean receivedFlag5,
2808                                        boolean receivedFlag6) throws DisconnectException {
2809        if (!receivedFlag || !receivedFlag2 || !receivedFlag3 || !receivedFlag4 ||
2810                !receivedFlag5 || !receivedFlag6) {
2811            doSyntaxrmSemantics(CodePoint.SYNERRCD_REQ_OBJ_NOT_FOUND);
2812        }
2813
2814    }
2815
2816    protected void checkRequiredObjects(boolean receivedFlag,
2817                                        boolean receivedFlag2,
2818                                        boolean receivedFlag3,
2819                                        boolean receivedFlag4,
2820                                        boolean receivedFlag5,
2821                                        boolean receivedFlag6,
2822                                        boolean receivedFlag7) throws DisconnectException {
2823        if (!receivedFlag || !receivedFlag2 || !receivedFlag3 || !receivedFlag4 ||
2824                !receivedFlag5 || !receivedFlag6 || !receivedFlag7) {
2825            doSyntaxrmSemantics(CodePoint.SYNERRCD_REQ_OBJ_NOT_FOUND);
2826        }
2827    }
2828
2829    // These methods are "private protected", which is not a recognized java privilege,
2830
// but means that these methods are private to this class and to subclasses,
2831
// and should not be used as package-wide friendly methods.
2832

2833    protected void doObjnsprmSemantics(int codePoint) throws DisconnectException {
2834        agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
2835            new ClientMessageId(SQLState.DRDA_DDM_OBJECT_NOT_SUPPORTED),
2836            Integer.toHexString(codePoint)));
2837    }
2838
2839    // Also called by NetStatementReply.
2840
protected void doPrmnsprmSemantics(int codePoint) throws DisconnectException {
2841        agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
2842            new ClientMessageId(SQLState.DRDA_DDM_PARAM_NOT_SUPPORTED),
2843            Integer.toHexString(codePoint)));
2844    }
2845
2846    // Also called by NetStatementReply
2847
void doValnsprmSemantics(int codePoint, int value) throws DisconnectException {
2848        doValnsprmSemantics(codePoint, Integer.toString(value));
2849    }
2850
2851    void doValnsprmSemantics(int codePoint, String JavaDoc value) throws DisconnectException {
2852
2853        // special case the FDODTA codepoint not to disconnect.
2854
if (codePoint == CodePoint.FDODTA) {
2855            agent_.accumulateReadException(new SqlException(agent_.logWriter_,
2856                new ClientMessageId(SQLState.DRDA_DDM_PARAMVAL_NOT_SUPPORTED),
2857                Integer.toHexString(codePoint)));
2858            return;
2859        }
2860
2861        if (codePoint == CodePoint.CCSIDSBC ||
2862                codePoint == CodePoint.CCSIDDBC ||
2863                codePoint == CodePoint.CCSIDMBC) {
2864            // the server didn't like one of the ccsids.
2865
// the message should reflect the error in question. right now these values
2866
// will be hard coded but this won't be correct if our driver starts sending
2867
// other values to the server. In order to pick up the correct values,
2868
// a little reorganization may need to take place so that this code (or
2869
// whatever code sets the message) has access to the correct values.
2870
int cpValue = 0;
2871            switch (codePoint) {
2872            case CodePoint.CCSIDSBC:
2873                cpValue = netAgent_.typdef_.getCcsidSbc();
2874                break;
2875            case CodePoint.CCSIDDBC:
2876                cpValue = netAgent_.typdef_.getCcsidDbc();
2877                break;
2878            case CodePoint.CCSIDMBC:
2879                cpValue = netAgent_.typdef_.getCcsidSbc();
2880                break;
2881            default:
2882                // should never be in this default case...
2883
cpValue = 0;
2884                break;
2885            }
2886            agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
2887                new ClientMessageId(SQLState.DRDA_NO_AVAIL_CODEPAGE_CONVERSION),
2888                new Integer JavaDoc(cpValue), value));
2889            return;
2890        }
2891        // the problem isn't with one of the ccsid values so...
2892

2893        // Returning more information would
2894
// require rearranging this code a little.
2895
agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
2896            new ClientMessageId(SQLState.DRDA_DDM_PARAMVAL_NOT_SUPPORTED),
2897            Integer.toHexString(codePoint)));
2898    }
2899
2900    void doDtamchrmSemantics() throws DisconnectException {
2901        agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
2902            new ClientMessageId(SQLState.DRDA_CONNECTION_TERMINATED),
2903                msgutil_.getTextMessage(MessageId.CONN_DRDA_DTARMCHRM)));
2904    }
2905
2906    // Messages
2907
// SQLSTATE : 58010
2908
// Execution failed due to a distribution protocol error that
2909
// will affect the successful execution of subsequent DDM commands
2910
// or SQL statements.
2911
// SQLCODE : -30021
2912
// Execution failed because of a Distributed Protocol
2913
// Error that will affect the successful execution of subsequent
2914
// commands and SQL statements: Manager <manager> at Level
2915
// <level> not supported.
2916
//
2917
// A system erro occurred that prevented successful connection
2918
// of the application to the remote database. This message (SQLCODE)
2919
// is producted for SQL CONNECT statement.
2920
private void doMgrlvlrmSemantics(String JavaDoc manager, String JavaDoc level) throws DisconnectException {
2921        agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
2922            new ClientMessageId(SQLState.DRDA_MGRLVLRM),
2923            manager, level));
2924    }
2925
2926    private void doMgrlvlrmSemantics(int manager, int level) throws DisconnectException {
2927        doMgrlvlrmSemantics("0x" + Integer.toHexString(manager),
2928                "0x" + Integer.toHexString(level));
2929    }
2930
2931    private void doMgrlvlrmSemantics(int[] nameList, int[] levelList) throws DisconnectException {
2932        StringBuffer JavaDoc managerNames = new StringBuffer JavaDoc(100);
2933        StringBuffer JavaDoc managerLevels = new StringBuffer JavaDoc(100);
2934
2935        int count = nameList.length;
2936        for (int i = 0; i < count; i++) {
2937            managerNames.append("0x");
2938            managerNames.append(nameList[i]);
2939            managerLevels.append("0x");
2940            managerLevels.append(levelList[i]);
2941            if (i != (count - 1)) {
2942                managerNames.append(",");
2943                managerLevels.append(",");
2944            }
2945        }
2946        doMgrlvlrmSemantics(managerNames.toString(), managerLevels.toString());
2947    }
2948
2949    // The client can detect that a conversational protocol error has occurred.
2950
// This can also be detected at the server in which case a PRCCNVRM is returned.
2951
// The Conversation Protocol Error Code, PRCCNVRM, describes the various errors.
2952
//
2953
// Note: Not all of these may be valid at the client. See descriptions for
2954
// which ones make sense for client side errors/checks.
2955
// Conversation Error Code Description of Error
2956
// ----------------------- --------------------
2957
// 0x01 RPYDSS received by target communications manager.
2958
// 0x02 Multiple DSSs sent without chaining or multiple
2959
// DSS chains sent.
2960
// 0x03 OBJDSS sent when not allowed.
2961
// 0x04 Request correlation identifier of an RQSDSS
2962
// is less than or equal to the previous
2963
// RQSDSS's request correlatio identifier in the chain.
2964
// 0x05 Request correlation identifier of an OBJDSS
2965
// does not equal the request correlation identifier
2966
// of the preceding RQSDSS.
2967
// 0x06 EXCSAT was not the first command after the connection
2968
// was established.
2969
// 0x10 ACCSEC or SECCHK command sent in wrong state.
2970
// 0x11 SYNCCTL or SYNCRSY command is used incorrectly.
2971
// 0x12 RDBNAM mismatch between ACCSEC, SECCHK, and ACCRDB.
2972
// 0x13 A command follows one that returned EXTDTAs as reply object.
2973
//
2974
// When the client detects these errors, it will be handled as if a PRCCNVRM is returned
2975
// from the server. In this PRCCNVRM case, PROTOCOL architects an SQLSTATE of 58008 or 58009
2976
// depening of the SVRCOD. In this case, a 58009 will always be returned.
2977
// Messages
2978
// SQLSTATE : 58009
2979
// Execution failed due to a distribution protocol error that caused deallocation of the conversation.
2980
// SQLCODE : -30020
2981
// Execution failed because of a Distributed Protocol
2982
// Error that will affect the successful execution of subsequent
2983
// commands and SQL statements: Reason Code <reason-code>.
2984
// Some possible reason codes include:
2985
// 121C Indicates that the user is not authorized to perform the requested command.
2986
// 1232 The command could not be completed because of a permanent error.
2987
// In most cases, the server will be in the process of an abend.
2988
// 220A The target server has received an invalid data description.
2989
// If a user SQLDA is specified, ensure that the fields are
2990
// initialized correctly. Also, ensure that the length does not
2991
// exceed the maximum allowed length for the data type being used.
2992
//
2993
// The command or statement cannot be processed. The current
2994
// transaction is rolled back and the application is disconnected
2995
// from the remote database.
2996
protected void doPrccnvrmSemantics(int conversationProtocolErrorCode) throws DisconnectException {
2997        // we may need to map the conversation protocol error code, prccnvcd, to some kind
2998
// of reason code. For now just return the prccnvcd as the reason code
2999
agent_.accumulateChainBreakingReadExceptionAndThrow(new DisconnectException(agent_,
3000            new ClientMessageId(SQLState.DRDA_CONNECTION_TERMINATED),
3001                msgutil_.getTextMessage(MessageId.CONN_DRDA_PRCCNVRM,
3002                    Integer.toHexString(conversationProtocolErrorCode))));
3003    }
3004
3005    // SQL Diagnostics Condition Token Array - Identity 0xF7
3006
// SQLNUMROW; ROW LID 0x68; ELEMENT TAKEN 0(all); REP FACTOR 1
3007
// SQLTOKROW; ROW LID 0xE7; ELEMENT TAKEN 0(all); REP FACTOR 0(all)
3008
void parseSQLDCTOKS() throws DisconnectException {
3009        if (readFastUnsignedByte() == CodePoint.NULLDATA) {
3010            return;
3011        }
3012        int num = parseFastSQLNUMROW();
3013        for (int i = 0; i < num; i++) {
3014            parseSQLTOKROW();
3015        }
3016    }
3017
3018    // SQL Diagnostics Condition Information Array - Identity 0xF5
3019
// SQLNUMROW; ROW LID 0x68; ELEMENT TAKEN 0(all); REP FACTOR 1
3020
// SQLDCIROW; ROW LID 0xE5; ELEMENT TAKEN 0(all); REP FACTOR 0(all)
3021
private void parseSQLDIAGCI(Sqlca[] rowsetSqlca) throws DisconnectException {
3022        if (readFastUnsignedByte() == CodePoint.NULLDATA) {
3023            return;
3024        }
3025        int num = parseFastSQLNUMROW();
3026        if (num == 0) {
3027            resetRowsetSqlca(rowsetSqlca, 0);
3028        }
3029
3030        // lastRow is the row number for the last row that had a non-null SQLCA.
3031
int lastRow = 1;
3032        for (int i = 0; i < num; i++) {
3033            lastRow = parseSQLDCROW(rowsetSqlca, lastRow);
3034        }
3035        resetRowsetSqlca(rowsetSqlca, lastRow + 1);
3036    }
3037
3038    // SQL Diagnostics Connection Array - Identity 0xF6
3039
// SQLNUMROW; ROW LID 0x68; ELEMENT TAKEN 0(all); REP FACTOR 1
3040
// SQLCNROW; ROW LID 0xE6; ELEMENT TAKEN 0(all); REP FACTOR 0(all)
3041
private void parseSQLDIAGCN() throws DisconnectException {
3042        if (readUnsignedByte() == CodePoint.NULLDATA) {
3043            return;
3044        }
3045        int num = parseFastSQLNUMROW();
3046        for (int i = 0; i < num; i++) {
3047            parseSQLCNROW();
3048        }
3049    }
3050
3051    // SQL Diagnostics Connection Row - Identity 0xE6
3052
// SQLCNGRP; GROUP LID 0xD6; ELEMENT TAKEN 0(all); REP FACTOR 1
3053
private void parseSQLCNROW() throws DisconnectException {
3054        parseSQLCNGRP();
3055    }
3056
3057    // SQL Diagnostics Condition Row - Identity 0xE5
3058
// SQLDCGRP; GROUP LID 0xD5; ELEMENT TAKEN 0(all); REP FACTOR 1
3059
private int parseSQLDCROW(Sqlca[] rowsetSqlca, int lastRow) throws DisconnectException {
3060        return parseSQLDCGRP(rowsetSqlca, lastRow);
3061    }
3062
3063    // SQL Diagnostics Token Row - Identity 0xE7
3064
// SQLTOKGRP; GROUP LID 0xD7; ELEMENT TAKEN 0(all); REP FACTOR 1
3065
private void parseSQLTOKROW() throws DisconnectException {
3066        parseSQLTOKGRP();
3067    }
3068
3069    // check on SQLTOKGRP format
3070
private void parseSQLTOKGRP() throws DisconnectException {
3071        skipFastNVCMorNVCS();
3072    }
3073
3074    // SQL Diagnostics Statement Group Description - Identity 0xD3
3075
// Nullable Group
3076
// SQLDSFCOD; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3077
// SQLDSCOST; PROTOCOL TYPE I4; ENVLID 0X02; Length Override 4
3078
// SQLDSLROW; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3079
// SQLDSNPM; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3080
// SQLDSNRS; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3081
// SQLDSRNS; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3082
// SQLDSDCOD; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3083
// SQLDSROWC; PROTOCOL TYPE FD; ENVLID 0x0E; Length Override 31
3084
// SQLDSNROW; PROTOCOL TYPE FD; ENVLID 0x0E; Length Override 31
3085
// SQLDSROWCS; PROTOCOL TYPE FD; ENVLID 0x0E; Length Override 31
3086
// SQLDSACON; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
3087
// SQLDSACRH; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
3088
// SQLDSACRS; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
3089
// SQLDSACSL; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
3090
// SQLDSACSE; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
3091
// SQLDSACTY; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
3092
// SQLDSCERR; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
3093
// SQLDSMORE; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
3094
private long parseSQLDIAGSTT(Sqlca[] rowsetSqlca) throws DisconnectException {
3095        if (readFastUnsignedByte() == CodePoint.NULLDATA) {
3096            return 0;
3097        }
3098        int sqldsFcod = readFastInt(); // FUNCTION_CODE
3099
int sqldsCost = readFastInt(); // COST_ESTIMATE
3100
int sqldsLrow = readFastInt(); // LAST_ROW
3101

3102        skipFastBytes(16);
3103
3104        long sqldsRowc = readFastLong(); // ROW_COUNT
3105

3106        skipFastBytes(24);
3107
3108        return sqldsRowc;
3109    }
3110
3111    // SQL Diagnostics Connection Group Description - Identity 0xD6
3112
// Nullable
3113
//
3114
// SQLCNSTATE; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3115
// SQLCNSTATUS; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3116
// SQLCNATYPE; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
3117
// SQLCNETYPE; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 1
3118
// SQLCNPRDID; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 8
3119
// SQLCNRDB; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
3120
// SQLCNCLASS; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
3121
// SQLCNAUTHID; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
3122
private void parseSQLCNGRP() throws DisconnectException {
3123        skipBytes(18);
3124        String JavaDoc sqlcnRDB = parseFastVCS(); // RDBNAM
3125
String JavaDoc sqlcnClass = parseFastVCS(); // CLASS_NAME
3126
String JavaDoc sqlcnAuthid = parseFastVCS(); // AUTHID
3127
}
3128
3129    // SQL Diagnostics Condition Group Description
3130
//
3131
// SQLDCCODE; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3132
// SQLDCSTATE; PROTOCOL TYPE FCS; ENVLID Ox30; Lengeh Override 5
3133
// SQLDCREASON; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3134
// SQLDCLINEN; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3135
// SQLDCROWN; PROTOCOL TYPE FD; ENVLID 0x0E; Lengeh Override 31
3136
// SQLDCER01; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3137
// SQLDCER02; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3138
// SQLDCER03; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3139
// SQLDCER04; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3140
// SQLDCPART; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3141
// SQLDCPPOP; PROTOCOL TYPE I4; ENVLID 0x02; Length Override 4
3142
// SQLDCMSGID; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 10
3143
// SQLDCMDE; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 8
3144
// SQLDCPMOD; PROTOCOL TYPE FCS; ENVLID 0x30; Length Override 5
3145
// SQLDCRDB; PROTOCOL TYPE VCS; ENVLID 0x32; Length Override 255
3146
// SQLDCTOKS; PROTOCOL TYPE N-RLO; ENVLID 0xF7; Length Override 0
3147
// SQLDCMSG_m; PROTOCOL TYPE NVMC; ENVLID 0x3F; Length Override 32672
3148
// SQLDCMSG_S; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 32672
3149
// SQLDCCOLN_m; PROTOCOL TYPE NVCM ; ENVLID 0x3F; Length Override 255
3150
// SQLDCCOLN_s; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3151
// SQLDCCURN_m; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3152
// SQLDCCURN_s; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3153
// SQLDCPNAM_m; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3154
// SQLDCPNAM_s; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3155
// SQLDCXGRP; PROTOCOL TYPE N-GDA; ENVLID 0xD3; Length Override 1
3156
private int parseSQLDCGRP(Sqlca[] rowsetSqlca, int lastRow) throws DisconnectException {
3157        int sqldcCode = readFastInt(); // SQLCODE
3158
String JavaDoc sqldcState = readFastString(5, Typdef.UTF8ENCODING); // SQLSTATE
3159
int sqldcReason = readFastInt(); // REASON_CODE
3160
int sqldcLinen = readFastInt(); // LINE_NUMBER
3161
int sqldcRown = (int) readFastLong(); // ROW_NUMBER
3162

3163        // save +20237 in the 0th entry of the rowsetSqlca's.
3164
// this info is going to be used when a subsequent fetch prior is issued, and if already
3165
// received a +20237 then we've gone beyond the first row and there is no need to
3166
// flow another fetch to the server.
3167
if (sqldcCode == 20237) {
3168            rowsetSqlca[0] = new NetSqlca(netAgent_.netConnection_,
3169                    sqldcCode,
3170                    sqldcState,
3171                    null);
3172        } else {
3173            if (rowsetSqlca[sqldcRown] != null) {
3174                rowsetSqlca[sqldcRown].resetRowsetSqlca(netAgent_.netConnection_,
3175                        sqldcCode,
3176                        sqldcState,
3177                        null);
3178            } else {
3179                rowsetSqlca[sqldcRown] = new NetSqlca(netAgent_.netConnection_,
3180                        sqldcCode,
3181                        sqldcState,
3182                        null);
3183            }
3184        }
3185
3186        // reset all entries between lastRow and sqldcRown to null
3187
for (int i = lastRow + 1; i < sqldcRown; i++) {
3188            rowsetSqlca[i] = null;
3189        }
3190
3191        skipFastBytes(47);
3192        String JavaDoc sqldcRdb = parseFastVCS(); // RDBNAM
3193
// skip the tokens for now, since we already have the complete message.
3194
parseSQLDCTOKS(); // MESSAGE_TOKENS
3195
String JavaDoc sqldcMsg = parseFastNVCMorNVCS(); // MESSAGE_TEXT
3196

3197        // skip the following for now.
3198
skipFastNVCMorNVCS(); // COLUMN_NAME
3199
skipFastNVCMorNVCS(); // PARAMETER_NAME
3200
skipFastNVCMorNVCS(); // EXTENDED_NAMES
3201

3202        parseSQLDCXGRP(); // SQLDCXGRP
3203
return sqldcRown;
3204    }
3205
3206    // SQL Diagnostics Extended Names Group Description - Identity 0xD5
3207
// Nullable
3208
//
3209
// SQLDCXRDB_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3210
// SQLDCXSCH_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3211
// SQLDCXNAM_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3212
// SQLDCXTBLN_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3213
// SQLDCXRDB_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3214
// SQLDCXSCH_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3215
// SQLDCXNAM_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3216
// SQLDCXTBLN_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3217
//
3218
// SQLDCXCRDB_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3219
// SQLDCXCSCH_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3220
// SQLDCXCNAM_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3221
// SQLDCXCRDB_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3222
// SQLDCXCSCH_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3223
// SQLDCXCNAM_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3224
//
3225
// SQLDCXRRDB_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3226
// SQLDCXRSCH_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3227
// SQLDCXRNAM_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3228
// SQLDCXRRDB_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3229
// SQLDCXRSCH_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3230
// SQLDCXRNAM_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3231
//
3232
// SQLDCXTRDB_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3233
// SQLDCXTSCH_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3234
// SQLDCXTNAM_m ; PROTOCOL TYPE NVCM; ENVLID 0x3F; Length Override 255
3235
// SQLDCXTRDB_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3236
// SQLDCXTSCH_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3237
// SQLDCXTNAM_s ; PROTOCOL TYPE NVCS; ENVLID 0x33; Length Override 255
3238
private void parseSQLDCXGRP() throws DisconnectException {
3239        if (readFastUnsignedByte() == CodePoint.NULLDATA) {
3240            return;
3241        }
3242        skipFastNVCMorNVCS(); // OBJECT_RDBNAM
3243
skipFastNVCMorNVCS(); // OBJECT_SCHEMA
3244
skipFastNVCMorNVCS(); // SPECIFIC_NAME
3245
skipFastNVCMorNVCS(); // TABLE_NAME
3246
String JavaDoc sqldcxCrdb = parseFastVCS(); // CONSTRAINT_RDBNAM
3247
skipFastNVCMorNVCS(); // CONSTRAINT_SCHEMA
3248
skipFastNVCMorNVCS(); // CONSTRAINT_NAME
3249
parseFastVCS(); // ROUTINE_RDBNAM
3250
skipFastNVCMorNVCS(); // ROUTINE_SCHEMA
3251
skipFastNVCMorNVCS(); // ROUTINE_NAME
3252
parseFastVCS(); // TRIGGER_RDBNAM
3253
skipFastNVCMorNVCS(); // TRIGGER_SCHEMA
3254
skipFastNVCMorNVCS(); // TRIGGER_NAME
3255
}
3256
3257    private String JavaDoc parseFastNVCMorNVCS() throws DisconnectException {
3258        String JavaDoc stringToBeSet = null;
3259        int vcm_length = 0;
3260        int vcs_length = 0;
3261        if (readFastUnsignedByte() != CodePoint.NULLDATA) {
3262            vcm_length = readFastUnsignedShort();
3263            if (vcm_length > 0) {
3264                stringToBeSet = readFastString(vcm_length, netAgent_.targetTypdef_.getCcsidMbcEncoding());
3265            }
3266            if (readFastUnsignedByte() != CodePoint.NULLDATA) {
3267                agent_.accumulateChainBreakingReadExceptionAndThrow(
3268                    new DisconnectException(agent_,
3269                        new ClientMessageId(
3270                            SQLState.NET_NVCM_NVCS_BOTH_NON_NULL)));
3271            }
3272        } else {
3273            if (readFastUnsignedByte() != CodePoint.NULLDATA) {
3274                vcs_length = readFastUnsignedShort();
3275                if (vcs_length > 0) {
3276                    stringToBeSet = readFastString(vcs_length, netAgent_.targetTypdef_.getCcsidSbcEncoding());
3277                }
3278            }
3279        }
3280        return stringToBeSet;
3281    }
3282
3283    private void skipFastNVCMorNVCS() throws DisconnectException {
3284        int vcm_length = 0;
3285        int vcs_length = 0;
3286        if (readFastUnsignedByte() != CodePoint.NULLDATA) {
3287            vcm_length = readFastUnsignedShort();
3288            if (vcm_length > 0)
3289            //stringToBeSet = readString (vcm_length, netAgent_.targetTypdef_.getCcsidMbcEncoding());
3290
{
3291                skipFastBytes(vcm_length);
3292            }
3293            if (readFastUnsignedByte() != CodePoint.NULLDATA) {
3294                agent_.accumulateChainBreakingReadExceptionAndThrow(
3295                    new DisconnectException(agent_,
3296                        new ClientMessageId(
3297                            SQLState.NET_NVCM_NVCS_BOTH_NON_NULL)));
3298            }
3299        } else {
3300            if (readFastUnsignedByte() != CodePoint.NULLDATA) {
3301                vcs_length = readFastUnsignedShort();
3302                if (vcs_length > 0)
3303                //stringToBeSet = readString (vcs_length, netAgent_.targetTypdef_.getCcsidSbcEncoding());
3304
{
3305                    skipFastBytes(vcs_length);
3306                }
3307            }
3308        }
3309    }
3310
3311    void resetRowsetSqlca(Sqlca[] rowsetSqlca, int row) {
3312        // rowsetSqlca can be null.
3313
int count = ((rowsetSqlca == null) ? 0 : rowsetSqlca.length);
3314        for (int i = row; i < count; i++) {
3315            rowsetSqlca[i] = null;
3316        }
3317    }
3318}
3319
3320
3321
3322
Popular Tags