org.apache.derby.impl.drda
Class DRDAConnThread

java.lang.Object
  extended byjava.lang.Thread
      extended byorg.apache.derby.impl.drda.DRDAConnThread
All Implemented Interfaces:
java.lang.Runnable

public class DRDAConnThread
extends java.lang.Thread


Field Summary
private static int[] ACCRDB_REQUIRED
           
private  AppRequester appRequester
           
protected  CcsidManager ccsidManager
           
private  boolean close
           
private  java.lang.Object closeSync
           
private static int COMMIT
           
private  int correlationID
           
private  int currentRequiredLength
           
private  Database database
           
private  java.sql.SQLException databaseAccessException
           
private static DecryptionManager decryptionManager
           
private  java.util.Vector errorManagers
           
private  java.util.Vector errorManagersLevel
           
private  java.util.Vector knownManagers
           
private static java.lang.String leftBrace
           
private  boolean logConnections
           
private  java.lang.Object logConnectionsSync
           
private static HeaderPrintWriter logStream
           
private static int MAX_REQUIRED_LEN
           
private static int MGRLVL_3
           
private static int MGRLVL_4
           
private static int MGRLVL_5
           
private static int MGRLVL_6
           
private static int MGRLVL_7
           
private  byte[] myPublicKey
           
private static byte NULL_VALUE
           
private  java.lang.String pkgcnstknStr
           
private  java.lang.String pkgid
           
private  java.lang.String rdbcolid
           
private  java.lang.String rdbnam
           
private  DDMReader reader
           
private  int[] required
           
private static java.lang.String rightBrace
           
private static int ROLLBACK
           
private  int secnumber
           
private  boolean sendWarningsOnCNTQRY
           
private  NetworkServerControlImpl server
           
private  Session session
           
private  java.io.InputStream sockis
           
private  java.io.OutputStream sockos
           
private  int sqlamLevel
           
private static java.lang.String SQLERRMC_MESSAGE_DELIMITER
          SQLERRMC_MESSAGE_DELIMITER When message argument tokes are sent, this value separates the tokens for mulitiple error messages
private static java.lang.String SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER
          SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER, When full message text is sent for severe errors.
private static java.lang.String SQLERRMC_TOKEN_DELIMITER
          SQLERRMC_TOKEN_DELIMITER separates message argument tokens
private static java.lang.String SYNTAX_ERR
           
private  long timeSlice
           
private  java.lang.Object timeSliceSync
           
private  java.util.Vector unknownManagers
           
private  DDMWriter writer
           
private  DRDAXAProtocol xaProto
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DRDAConnThread(Session session, NetworkServerControlImpl server, long timeSlice, boolean logConnections)
          Create a new Thread for processing session requests
 
Method Summary
private  void addDatabase(java.lang.String dbname)
          Add a database to the current session
protected  void agentError(java.lang.String msg)
          Agent error - something very bad happened
private  void badObjectLength(int codePoint)
          Object length not allowed
private  java.lang.String buildPreformattedSqlerrmc(java.sql.SQLException se)
          Build preformatted SQLException text for severe exceptions or SQLExceptions that are not EmbedSQLExceptions.
protected  java.lang.String buildRuntimeInfo(java.lang.String indent, LocalizedResource localLangUtil)
           
private  java.lang.String buildSqlerrmc(java.sql.SQLException se)
          Create error message or message argements to return to client.
private  java.lang.String buildTokenizedSqlerrmc(EmbedSQLException se)
          Build Tokenized SQLERRMC to just send the tokenized arguments to the client.
private  boolean canIgnoreStmt(java.lang.String stmt)
           
private  void checkLength(int codepoint, int reqlen)
          Check that the length is equal to the required length for this codepoint
private  void checkRequired(int codePoint)
          Check whether we have seen all the required code points
private  void checkValidTypDefNam(java.lang.String typdefnam)
          check that the given typdefnam is acceptable
private  void checkWarning(java.sql.Connection conn, java.sql.Statement stmt, java.sql.ResultSet rs, int updateCount, boolean alwaysSend, boolean sendWarn)
          Check SQLWarning and write SQLCARD as needed.
protected  void close()
          Close DRDA connection thread
private  boolean closed()
          Test if DRDA connection thread is closed
private  void closeSession()
          Close the current session
protected  void codePointNotSupported(int codePoint)
          Don't support this code point
private  java.lang.String convertToHexString(byte[] buf)
          convert byte array to a Hex string
private  void copyToRequired(int[] req)
          Copy a list of required code points to template for checking
private  void doneData(DRDAStatement stmt, java.sql.ResultSet rs)
          Done data Send SQLCARD for the end of the data
private  void errorInChain(java.sql.SQLException e)
          If there's a severe error in the DDM chain, and if the header indicates "terminate chain on error", we stop processing further commands in the chain nor do we send any reply for them.
private  void exchangeServerAttributes()
          Exchange server attributes with application requester
private  void finalizeChain()
          Finalize the current DSS chain and send it if needed.
private  int getByteOrder()
           
private  int getConnFromDatabaseName()
          Get connection from a database name Username and password is verified by making a connection to the database
protected  int getCorrelationID()
          Get correlation id
protected  byte[] getCrrtkn()
          Get correlation token
protected  Database getDatabase()
          Get Database we are working on
protected  java.lang.String getDbName()
          Get database name
private  int getExceptionSeverity(java.sql.SQLException e)
          Translate from Cloudscape exception severity to SVRCOD
protected  java.io.InputStream getInputStream()
          Get input stream
private  boolean getLogConnections()
          Get whether connections are logged
protected  java.io.OutputStream getOutputStream()
          Get output stream
private  int getRdbAccessErrorCodePoint()
           
protected  DDMReader getReader()
          get DDMReader
protected  NetworkServerControlImpl getServer()
          Get server
protected  Session getSession()
          Get session we are working on
private  int getSqlCode(int severity)
           
private  long getTimeSlice()
          Get time slice value for length of time to work on a session
protected  DDMWriter getWriter()
          get DDMWriter
private  void handleException(java.lang.Exception e)
          Handle Exceptions - write error protocol if appropriate and close session or thread as appropriate
private  void initialize()
          Initialize class
private  void initializeForSession()
          Initialize for a new session
protected  void invalidCodePoint(int codePoint)
          Invalid codepoint for this command
private  void invalidValue(int codePoint)
          Invalid value for this code point
protected  void markCommunicationsFailure(java.lang.String arg1, java.lang.String arg2, java.lang.String arg3, java.lang.String arg4)
          Indicate a communications failure
protected  void missingCodePoint(int codePoint)
          Missing code point
private  int parseACCRDB()
          Parse access RDB Instance variables RDBACCCL - RDB Access Manager Class - required must be SQLAM CRRTKN - Correlation Token - required RDBNAM - Relational database name -required PRDID - Product specific identifier - required TYPDEFNAM - Data Type Definition Name -required TYPDEFOVR - Type definition overrides -required RDBALWUPD - RDB Allow Updates optional PRDDTA - Product Specific Data - optional - ignorable STTDECDEL - Statement Decimal Delimiter - optional STTSTRDEL - Statement String Delimiter - optional TRGDFTRT - Target Default Value Return - optional
private  int parseACCSEC()
          Parse Access Security If the target server supports the SECMEC requested by the application requester then a single value is returned and it is identical to the SECMEC value in the ACCSEC command.
private  java.lang.String parseCcsidMBC(int length)
          Parse mixed character string
private  java.lang.String parseCcsidSBC(int length)
          Parse single byte character string
private  DRDAStatement parseCLSQRY()
          Parse CLSQRY Instance Variables RDBNAM - relational database name - optional PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required QRYINSID - Query Instance Identifier - required - level 7 MONITOR - Monitor events - optional.
private  DRDAStatement parseCNTQRY()
          Parse CNTQRY - Continue Query Instance Variables RDBNAM - Relational Database Name - optional PKGNAMCSN - RDB Package Name, Consistency Token, and Section Number - required QRYBLKSZ - Query Block Size - required QRYRELSCR - Query Relative Scrolling Action - optional QRYSCRORN - Query Scroll Orientation - optional - level 7 QRYROWNBR - Query Row Number - optional QRYROWSNS - Query Row Sensitivity - optional - level 7 QRYBLKRST - Query Block Reset - optional - level 7 QRYRTNDTA - Query Returns Data - optional - level 7 QRYROWSET - Query Rowset Size - optional - level 7 QRYRFRTBL - Query Refresh Answer Set Table - optional NBRROW - Number of Fetch or Insert Rows - optional MAXBLKEXT - Maximum number of extra blocks - optional RTNEXTDTA - Return of EXTDTA Option - optional MONITOR - Monitor events - optional.
private  void parseCNTQRYobjects(DRDAStatement stmt)
          Parse CNTQRY objects Instance Variables OUTOVR - Output Override Descriptor - optional
private  boolean parseDRDAConnection()
           
private  boolean parseDSCSQLSTT()
          Parse DSCSQLSTT - Describe SQL Statement previously prepared Instance Variables TYPSQLDA - sqlda type expected (output or input) RDBNAM - relational database name - optional PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required MONITOR - Monitor events - optional.
private  java.lang.String parseEncodedString()
          Parse an encoded data string from the Application Requester
private  void parseEXCSAT()
          Parses EXCSAT (Exchange Server Attributes) Instance variables EXTNAM(External Name) - optional MGRLVLLS(Manager Levels) - optional SPVNAM(Supervisor Name) - optional SRVCLSNM(Server Class Name) - optional SRVNAM(Server Name) - optional, ignorable SRVRLSLV(Server Product Release Level) - optional, ignorable
private  void parseEXCSAT2()
          Parses EXCSAT2 (Exchange Server Attributes) Instance variables EXTNAM(External Name) - optional MGRLVLLS(Manager Levels) - optional SPVNAM(Supervisor Name) - optional SRVCLSNM(Server Class Name) - optional SRVNAM(Server Name) - optional, ignorable SRVRLSLV(Server Product Release Level) - optional, ignorable
private  int parseEXCSQLIMM()
          Parse EXCSQLIMM - Execute Immediate Statement Instance Variables RDBNAM - relational database name - optional PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required RDBCMTOK - RDB Commit Allowed - optional MONITOR - Monitor Events - optional Command Objects TYPDEFNAM - Data Type Definition Name - optional TYPDEFOVR - TYPDEF Overrides -optional SQLSTT - SQL Statement -required
private  boolean parseEXCSQLSET()
          Parse EXCSQLSET - Execute Set SQL Environment Instance Variables RDBNAM - relational database name - optional PKGNAMCT - RDB Package Name, Consistency Token - optional MONITOR - Monitor Events - optional Command Objects TYPDEFNAM - Data Type Definition Name - required TYPDEFOVR - TYPDEF Overrides - required SQLSTT - SQL Statement - required (at least one; may be more)
private  void parseEXCSQLSETobjects()
          Parse EXCSQLSET objects Objects TYPDEFNAM - Data type definition name - optional TYPDEFOVR - Type defintion overrides - optional SQLSTT - SQL Statement - required (a list of at least one) Objects may follow in one DSS or in several DSS chained together.
private  void parseEXCSQLSTT()
          Parse EXCSQLSTT - Execute non-cursor SQL Statement previously prepared Instance Variables RDBNAM - relational database name - optional PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required OUTEXP - Output expected NBRROW - Number of rows to be inserted if it's an insert PRCNAM - procedure name if specified by host variable, not needed for Cloudscape QRYBLKSZ - query block size MAXRSLCNT - max resultset count MAXBLKEXT - Max number of extra blocks RSLSETFLG - resultset flag RDBCMTOK - RDB Commit Allowed - optional OUTOVROPT - output override option QRYROWSET - Query Rowset Size - Level 7 MONITOR - Monitor events - optional.
private  void parseEXCSQLSTTobjects(DRDAStatement stmt)
          Parse EXCSQLSTT command objects Command Objects TYPDEFNAM - Data Type Definition Name - optional TYPDEFOVR - TYPDEF Overrides -optional SQLDTA - optional, variable data, specified if prpared statement has input parameters EXTDTA - optional, externalized FD:OCA data OUTOVR - output override descriptor, not allowed for stored procedure calls If TYPDEFNAM and TYPDEFOVR are supplied, they apply to the objects sent with the statement.
private  java.lang.String parseEXECSQLIMMobjects()
          Parse EXCSQLIMM objects Objects TYPDEFNAM - Data type definition name - optional TYPDEFOVR - Type defintion overrides SQLSTT - SQL Statement required If TYPDEFNAM and TYPDEFOVR are supplied, they apply to the objects sent with the statement.
private  void parseMGRLVLLS(int time)
          Parse manager levels Instance variables MGRLVL - repeatable, required CODEPOINT CCSIDMGR - CCSID Manager CMNAPPC - LU 6.2 Conversational Communications Manager CMNSYNCPT - SNA LU 6.2 SyncPoint Conversational Communications Manager CMNTCPIP - TCP/IP Communication Manager DICTIONARY - Dictionary RDB - Relational Database RSYNCMGR - Resynchronization Manager SECMGR - Security Manager SQLAM - SQL Application Manager SUPERVISOR - Supervisor SYNCPTMGR - Sync Point Manager VALUE On the second appearance of this codepoint, it can only add managers
private  void parseMONITOR()
          Parse MONITOR DRDA spec says this is optional.
private  java.lang.String parseNOCMorNOCS()
          Parse nullable character mixed byte or nullable character single byte Format 1 byte - null indicator I4 - mixed character length N bytes - mixed character string 1 byte - null indicator I4 - single character length N bytes - single character length string
private  java.lang.String parseOPNQRY()
          Parse OPNQRY Instance Variables RDBNAM - relational database name - optional PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required QRYBLKSZ - Query Block Size - required QRYBLKCTL - Query Block Protocol Control - optional MAXBLKEXT - Maximum Number of Extra Blocks - optional - default value 0 OUTOVROPT - Output Override Option QRYROWSET - Query Rowset Size - optional - level 7 MONITOR - Monitor events - optional.
private  void parseOPNQRYobjects(DRDAStatement stmt)
          Parse OPNQRY objects Objects TYPDEFNAM - Data type definition name - optional TYPDEFOVR - Type defintion overrides - optional SQLDTA- SQL Program Variable Data - optional If TYPDEFNAM and TYPDEFOVR are supplied, they apply to the objects sent with the statement.
private  void parseOUTOVR(DRDAStatement stmt)
          Parse OUTOVR - Output Override Descriptor This specifies the output format for data to be returned as output to a SQL statement or as output from a query.
private  int parseOUTOVROPT()
          Parse OUTOVROPT - this indicates whether output description can be overridden on just the first CNTQRY or on any CNTQRY
private  java.lang.String parsePKGNAMCSN()
          Parse PKGNAMCSN - RDB Package Name, Consistency Token, and Section Number Instance Variables NAMESYMDR - database name - not validated RDBCOLID - RDB Collection Identifier PKGID - RDB Package Identifier PKGCNSTKN - RDB Package Consistency Token PKGSN - RDB Package Section Number
private  java.lang.String parsePKGNAMCT()
           
private  int parsePRPSQLSTT()
          Parse PRPSQLSTT - Prepare SQL Statement Instance Variables RDBNAM - Relational Database Name - optional PKGNAMCAN - RDB Package Name, Consistency Token, and Section Number - required RTNSQLDA - Return SQL Descriptor Area - optional MONITOR - Monitor events - optional.
private  java.lang.String parsePRPSQLSTTobjects(DRDAStatement stmt)
          Parse PRPSQLSTT objects Objects TYPDEFNAM - Data type definition name - optional TYPDEFOVR - Type defintion overrides - optional SQLSTT - SQL Statement required SQLATTR - Cursor attributes on prepare - optional - level 7 If TYPDEFNAM and TYPDEFOVR are supplied, they apply to the objects sent with the statement.
private  int parseQRYBLKSZ()
          Parse QRYBLSZ - this gives the maximum size of the query blocks that can be returned to the requester
private  int parseQRYCLSIMP()
          Parse a QRYCLSIMP - Implicitly close non-scrollable cursor after end of data.
private  int parseQRYCLSRLS()
           
private  int parseQRYOPTVAL()
           
private  int parseQRYROWSET(int minVal)
          Parse QRYROWSET - this is the number of rows to return
private  void parseRDBCMTOK()
          Parse RDBCMTOK - tells the database whether to allow commits or rollbacks to be executed as part of the command Since we don't have a SQL commit or rollback command, we will just ignore this for now
private  java.lang.String parseRDBNAM()
          Parse database name
private  int parseSECCHK()
          Parse security check Instance Variables SECMGRNM - security manager name - optional, ignorable SECMEC - security mechanism - required SECTKN - security token - optional, (required if encryption used) PASSWORD - password - optional, (required if security mechanism uses it) NEWPASSWORD - new password - optional, (required if sec mech. uses it) USRID - user id - optional, (required if sec mec. uses it) RDBNAM - database name - optional (required if databases can have own sec.)
protected  void parseSQLATTR(DRDAStatement stmt)
          Parse SQLATTR - Cursor attributes on prepare This is an encoded string.
private  void parseSQLDTA_work(DRDAStatement stmt)
          Parse SQLDTA - SQL program variable data Instance Variables FDODSC - FD:OCA data descriptor - required FDODTA - FD:OCA data - optional
private  void parseSQLDTA(DRDAStatement stmt)
          Parse SQLDTA - SQL program variable data and handle exception.
private  java.lang.String parseSQLSTTDss()
          Parse SQLSTT Dss
private  java.lang.String parseTYPDEFNAM()
          Parse TYPDEFNAM
private  void parseTYPDEFOVR(DRDAStatement st)
          Parse Type Defintion Overrides TYPDEF Overrides specifies the Coded Character SET Identifiers (CCSIDs) that are in a named TYPDEF.
private  boolean parseTYPSQLDA()
          Parse TYPSQLDA - Type of the SQL Descriptor Area
private  java.lang.String parseVCMorVCS()
          Parse variable character mixed byte or variable character single byte Format I2 - VCM Length N bytes - VCM value I2 - VCS Length N bytes - VCS value Only 1 of VCM length or VCS length can be non-zero
private  boolean positionCursor(DRDAStatement stmt, java.sql.ResultSet rs)
          Position cursor for insensitive scrollable cursors
protected static void println2Log(java.lang.String dbname, java.lang.String drdaID, java.lang.String msg)
          Print a line to the DB2j log
private  void processCommands()
          Process DRDA commands we can receive once server attributes have been exchanged.
private  void rdbnamMismatch(int codePoint)
          Database name given under code point doesn't match previous database names
private  void rdbNotFound(java.lang.String rdbnam)
          RDB not found
private  void readAndSetAllExtParams(DRDAStatement stmt)
           
private  void readAndSetExtParam(int i, DRDAStatement stmt, int drdaType, int extLen)
          Read different types of input parameters and set them in PreparedStatement
private  java.util.ArrayList readAndSetParams(int i, DRDAStatement stmt, int drdaType, EmbedParameterSetMetaData pmeta, java.util.ArrayList paramExtPositions, int paramLenNumBytes)
          Read different types of input parameters and set them in PreparedStatement
private  boolean readBoolean(int codepoint)
          Read and check a boolean value
private  long readLobLength(int extLenIndicator)
           
private  void removeFromRequired(int codePoint)
          Remove codepoint from required list
 void run()
          Main routine for thread, loops until the thread is closed Gets a session, does work for the session
private  void sendUnexpectedException(java.lang.Exception e)
          Send unpexpected error to the client
private  void sessionInitialState()
          In initial state for a session, determine whether this is a command session or a DRDA protocol session.
private  void setDatabase(int codePoint)
          Set the current database
protected  void setLogConnections(boolean value)
          Set logging of connections
private  void setStmtOrDbByteOrder(boolean setDatabase, DRDAStatement stmt, java.lang.String typDefNam)
          Set a statement or the database' byte order, depending on the arguments
protected  void setTimeSlice(long value)
          Set time slice value
static void showmem()
          Show runtime memory
private  void skipRemainder(boolean onlySkipSameIds)
          Skip remainder of current DSS and all chained DSS'es
private  void splitQRYDTA(DRDAStatement stmt, int blksize)
          Split QRYDTA into blksize chunks
private  int svrcodFromSecchkcd(int securityCheckCode)
          Calculate SVRCOD value from SECCHKCD
protected  void throwSyntaxrm(int errcd, int cpArg)
          Syntax error
private  void tooBig(int codePoint)
          Object too big
private  void tooMany(int codePoint)
          Seen too many of this code point
protected  void trace(java.lang.String value)
          Send string to console
private  void valueNotSupported(int codePoint)
          Don't support this value
private  void verifyInOrderACCSEC_SECCHK(int codePoint, int reqCodePoint)
          Verify that the code point is in the right order
private  void verifyRequiredObject(int codePoint, int reqCodePoint)
          Verify that the code point is the required code point
private  int verifyUserIdPassword()
          Verify userId and password Username and password is verified by making a connection to the database
private  void writeABNUOWRM()
          Write ABNUOWRM - query process has terminated in an error condition such as deadlock or lock timeout.
private  void writeACCRDBRM(int svrcod)
          Write Access to RDB Completed Instance Variables SVRCOD - severity code - 0 info, 4 warning -required PRDID - product specific identifier -required TYPDEFNAM - type definition name -required TYPDEFOVR - type definition overrides - required RDBINTTKN - token which can be used to interrupt DDM commands - optional CRRTKN - correlation token - only returned if we didn't get one from requester SRVDGN - server diagnostic information - optional PKGDFTCST - package default character subtype - optional USRID - User ID at the target system - optional SRVLST - Server List
private  void writeACCSECRD(int securityCheckCode)
          Write ACCSECRD If the security mechanism is known, we just send it back along with the security token if encryption is going to be used.
private  void writeCMDCHKRM(int severity)
          Write CMDCHKRM Instance Variables SVRCOD - Severity Code - required
private  void writeENDQRYRM(int svrCod)
          Write ENDQRYRM - query process has terminated in such a manner that the query or result set is now closed.
private  void writeENDUOWRM(int opType)
          Write ENDUOWRM Instance Variables SVCOD - severity code - WARNING - required UOWDSP - Unit of Work Disposition - required RDBNAM - Relational Database name - optional SRVDGN - Server Diagnostics information - optional
private  void writeEXCSATRD()
          Write reply to EXCSAT command Instance Variables EXTNAM - External Name (optional) MGRLVLLS - Manager Level List (optional) SRVCLSNM - Server Class Name (optional) - used by JCC SRVNAM - Server Name (optional) SRVRLSLV - Server Product Release Level (optional)
(package private)  void writeEXTDTA(DRDAStatement stmt)
           
protected  void writeFdocaVal(int index, java.lang.Object val, int drdaType, int precision, int scale, boolean valNull, DRDAStatement stmt)
          Write Fdoca Value to client
private  boolean writeFDODTA(DRDAStatement stmt)
           
private  void writeMGRLEVELS()
          Write manager levels The target server must not provide information for any target managers unless the source explicitly requests it.
private  void writeNullability(int drdaType, boolean valNull)
          write nullability if this is a nullable drdatype and FDOCA null value if appropriate
private  void writeNullSQLCARDobject()
          Write a null SQLCARD as an object
private  void writeOPNQFLRM(java.sql.SQLException e)
          Write a OPNQFLRM - Open Query Failure Instance Variables SVRCOD - Severity Code - required - 8 ERROR RDBNAM - Relational Database Name - required
private  void writeOPNQRYRM(boolean isDssObject, DRDAStatement stmt)
          Write OPNQRYRM - Open Query Complete Instance Variables SVRCOD - Severity Code - required QRYPRCTYP - Query Protocol Type - required SQLCSRHLD - Hold Cursor Position - optional QRYATTSCR - Query Attribute for Scrollability - optional - level 7 QRYATTSNS - Query Attribute for Sensitivity - optional - level 7 QRYATTUPD - Query Attribute for Updatability -optional - level 7 QRYINSID - Query Instance Identifier - required - level 7 SRVDGN - Server Diagnostic Information - optional
private  void writePKGNAMCSN()
           
private  void writePKGNAMCSN(java.lang.String pkgcnstknStr)
          Write PKGNAMCSN Instance Variables NAMESYMDR - database name - not validated RDBCOLID - RDB Collection Identifier PKGID - RDB Package Identifier PKGCNSTKN - RDB Package Consistency Token PKGSN - RDB Package Section Number There are two possible formats, fixed and extended which includes length information for the strings
private  void writeQRYDSC(DRDAStatement stmt, boolean FDODSConly)
          Write QRYDSC - Query Answer Set Description
private  void writeQRYDTA(DRDAStatement stmt)
          Write QRYDTA - Query Answer Set Data Contains some or all of the answer set data resulting from a query returns true if there is more data, false if we reached the end Instance Variables Byte string
private  void writeQRYNOPRM(int svrCod)
          Write a QRYNOPRM - Query Not Opened Instance Variables SVRCOD - Severity Code - required - 4 Warning 8 ERROR RDBNAM - Relational Database Name - required PKGNAMCSN - RDB Package Name, Consistency Token, and Section Number - required
private  void writeQRYPOPRM()
          Write a QRYPOPRM - Query Previously opened Instance Variables SVRCOD - Severity Code - required - 8 ERROR RDBNAM - Relational Database Name - required PKGNAMCSN - RDB Package Name, Consistency Token, and Section Number - required
private  void writeRDBfailure(int codePoint)
          Write RDB Failure Instance Variables SVRCOD - Severity Code - required RDBNAM - Relational Database name - required SRVDGN - Server Diagnostics - optional (not sent for now)
protected  void writeRDBNAM(java.lang.String rdbnam)
          Write RDBNAM
private  void writeRDBUPDRM()
          Write RDBUPDRM Instance variables SVRCOD - Severity code - Information only - required RDBNAM - Relational database name -required SRVDGN - Server Diagnostic Information -optional
private  void writeRSLSETRM(DRDAStatement stmt)
          Write RSLSETRM Instance variables SVRCOD - Severity code - Information only - required PKGSNLST - list of PKGNAMCSN -required SRVDGN - Server Diagnostic Information -optional
private  void writeSECCHKRM(int securityCheckCode)
          Write security check reply Instance variables SVRCOD - serverity code - required SECCHKCD - security check code - required SECTKN - security token - optional, ignorable SVCERRNO - security service error number SRVDGN - Server Diagnostic Information
private  void writeSQLCAERRWARN(int updateCount, long rowCount)
          Write the ERR and WARN part of the SQLCA
private  void writeSQLCAGRP(java.sql.SQLException e, int sqlcode, int updateCount, long rowCount)
          Write SQLCAGRP SQLCAGRP : FDOCA EARLY GROUP SQL Communcations Area Group Description FORMAT FOR SQLAM <= 6 SQLCODE; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLSTATE; DRDA TYPE FCS; ENVLID 0x30; Length Override 5 SQLERRPROC; DRDA TYPE FCS; ENVLID 0x30; Length Override 8 SQLCAXGRP; DRDA TYPE N-GDA; ENVLID 0x52; Length Override 0 FORMAT FOR SQLAM >= 7 SQLCODE; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLSTATE; DRDA TYPE FCS; ENVLID 0x30; Length Override 5 SQLERRPROC; DRDA TYPE FCS; ENVLID 0x30; Length Override 8 SQLCAXGRP; DRDA TYPE N-GDA; ENVLID 0x52; Length Override 0 SQLDIAGGRP; DRDA TYPE N-GDA; ENVLID 0x56; Length Override 0
private  void writeSQLCARD(java.sql.SQLException e, int severity, int updateCount, long rowCount)
           
private  void writeSQLCARDs(java.sql.SQLException e, int updateCount)
           
private  void writeSQLCARDs(java.sql.SQLException e, int updateCount, boolean sendSQLERRRM)
           
private  void writeSQLCAXGRP(int updateCount, long rowCount, java.lang.String sqlerrmc, java.sql.SQLException nextException)
          Write SQLCAXGRP SQLCAXGRP : EARLY FDOCA GROUP SQL Communications Area Exceptions Group Description FORMAT FOR SQLAM <= 6 SQLRDBNME; DRDA TYPE FCS; ENVLID 0x30; Length Override 18 SQLERRD1; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD2; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD3; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD4; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD5; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD6; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLWARN0; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN1; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN2; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN3; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN4; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN5; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN6; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN7; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN8; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN9; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARNA; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLERRMSG_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 70 SQLERRMSG_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 70 FORMAT FOR SQLAM >= 7 SQLERRD1; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD2; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD3; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD4; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD5; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD6; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLWARN0; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN1; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN2; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN3; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN4; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN5; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN6; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN7; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN8; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN9; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARNA; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLRDBNAME; DRDA TYPE VCS; ENVLID 0x32; Length Override 255 SQLERRMSG_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 70 SQLERRMSG_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 70
private  void writeSQLCINRD(DRDAStatement stmt)
          Write SQLCINRD - result set column information
private  void writeSQLDAGRP(java.sql.ResultSetMetaData rsmeta, EmbedParameterSetMetaData pmeta, int elemNum, boolean rtnOutput)
          Write SQLDAGRP SQLDAGRP : EARLY FDOCA GROUP SQL Data Area Group Description FORMAT FOR SQLAM <= 6 SQLPRECISION; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLSCALE; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLLENGTH; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLTYPE; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLCCSID; DRDA TYPE FB; ENVLID 0x26; Length Override 2 SQLNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 30 SQLNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 30 SQLLABEL_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 30 SQLLABEL_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 30 SQLCOMMENTS_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 254 SQLCOMMENTS_m; DRDA TYPE VCS; ENVLID 0x32; Length Override 254 FORMAT FOR SQLAM == 6 SQLPRECISION; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLSCALE; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLLENGTH; DRDA TYPE I8; ENVLID 0x16; Length Override 8 SQLTYPE; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLCCSID; DRDA TYPE FB; ENVLID 0x26; Length Override 2 SQLNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 30 SQLNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 30 SQLLABEL_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 30 SQLLABEL_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 30 SQLCOMMENTS_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 254 SQLCOMMENTS_m; DRDA TYPE VCS; ENVLID 0x32; Length Override 254 SQLUDTGRP; DRDA TYPE N-GDA; ENVLID 0x51; Length Override 0 FORMAT FOR SQLAM >= 7 SQLPRECISION; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLSCALE; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLLENGTH; DRDA TYPE I8; ENVLID 0x16; Length Override 8 SQLTYPE; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLCCSID; DRDA TYPE FB; ENVLID 0x26; Length Override 2 SQLDOPTGRP; DRDA TYPE N-GDA; ENVLID 0xD2; Length Override 0
private  void writeSQLDARD(DRDAStatement stmt, boolean rtnOutput, java.sql.SQLException e)
          Write SQLDARD SQLDARD : FDOCA EARLY ARRAY SQL Descriptor Area Row Description with SQL Communications Area FORMAT FOR SQLAM <= 6 SQLCARD; ROW LID 0x64; ELEMENT TAKEN 0(all); REP FACTOR 1 SQLNUMROW; ROW LID 0x68; ELEMENT TAKEN 0(all); REP FACTOR 1 SQLDAROW; ROW LID 0x60; ELEMENT TAKEN 0(all); REP FACTOR 0(all) FORMAT FOR SQLAM >= 7 SQLCARD; ROW LID 0x64; ELEMENT TAKEN 0(all); REP FACTOR 1 SQLDHROW; ROW LID 0xE0; ELEMENT TAKEN 0(all); REP FACTOR 1 SQLNUMROW; ROW LID 0x68; ELEMENT TAKEN 0(all); REP FACTOR 1
private  void writeSQLDCGRP(long rowNum, int sqlCode, java.lang.String sqlState, java.lang.String dbname, java.lang.String sqlerrmc)
          writeSQLDCGRP: SQL Diagnostics Condition Group Description SQLDCCODE; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCSTATE; DRDA TYPE FCS; ENVLID Ox30; Lengeh Override 5 SQLDCREASON; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCLINEN; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCROWN; DRDA TYPE FD; ENVLID 0x0E; Lengeh Override 31 SQLDCER01; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCER02; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCER03; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCER04; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCPART; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCPPOP; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCMSGID; DRDA TYPE FCS; ENVLID 0x30; Length Override 10 SQLDCMDE; DRDA TYPE FCS; ENVLID 0x30; Length Override 8 SQLDCPMOD; DRDA TYPE FCS; ENVLID 0x30; Length Override 5 SQLDCRDB; DRDA TYPE VCS; ENVLID 0x32; Length Override 255 SQLDCTOKS; DRDA TYPE N-RLO; ENVLID 0xF7; Length Override 0 SQLDCMSG_m; DRDA TYPE NVMC; ENVLID 0x3F; Length Override 32672 SQLDCMSG_S; DRDA TYPE NVCS; ENVLID 0x33; Length Override 32672 SQLDCCOLN_m; DRDA TYPE NVCM ; ENVLID 0x3F; Length Override 255 SQLDCCOLN_s; DRDA TYPE NVCS; ENVLID 0x33; Length Override 255 SQLDCCURN_m; DRDA TYPE NVCM; ENVLID 0x3F; Length Override 255 SQLDCCURN_s; DRDA TYPE NVCS; ENVLID 0x33; Length Override 255 SQLDCPNAM_m; DRDA TYPE NVCM; ENVLID 0x3F; Length Override 255 SQLDCPNAM_s; DRDA TYPE NVCS; ENVLID 0x33; Length Override 255 SQLDCXGRP; DRDA TYPE N-GDA; ENVLID 0xD3; Length Override 1
private  void writeSQLDCROW(long rowNum, int sqlCode, java.lang.String sqlState, java.lang.String dbname, java.lang.String sqlerrmc)
          writeSQLDCROW: SQL Diagnostics Condition Row - Identity 0xE5 SQLDCGRP; GROUP LID 0xD5; ELEMENT TAKEN 0(all); REP FACTOR 1
private  void writeSQLDHROW(DRDAStatement stmt)
           
private  void writeSQLDIAGCI(java.sql.SQLException nextException)
          writeSQLDIAGCI: SQL Diagnostics Condition Information Array - Identity 0xF5 SQLNUMROW; ROW LID 0x68; ELEMENT TAKEN 0(all); REP FACTOR 1 SQLDCIROW; ROW LID 0xE5; ELEMENT TAKEN 0(all); REP FACTOR 0(all)
private  void writeSQLDIAGCN()
           
private  void writeSQLDIAGGRP(java.sql.SQLException nextException)
          Write SQLDIAGGRP: SQL Diagnostics Group Description - Identity 0xD1 Nullable Group SQLDIAGSTT; DRDA TYPE N-GDA; ENVLID 0xD3; Length Override 0 SQLDIAGCN; DRFA TYPE N-RLO; ENVLID 0xF6; Length Override 0 SQLDIAGCI; DRDA TYPE N-RLO; ENVLID 0xF5; Length Override 0
private  void writeSQLDIAGSTT()
           
private  void writeSQLDOPTGRP(java.sql.ResultSetMetaData rsmeta, EmbedParameterSetMetaData pmeta, int jdbcElemNum, boolean rtnOutput)
           
private  void writeSQLDTAGRP(DRDAStatement stmt, java.sql.ResultSetMetaData rsmeta, EmbedParameterSetMetaData pmeta, int colStart, int colEnd, boolean first)
          Write SQLDTAGRP SQLDAGRP : Late FDOCA GROUP SQL Data Value Group Descriptor LENGTH - length of the SQLDTAGRP TRIPLET_TYPE - NGDA for first, CPT for following ID - SQLDTAGRP_LID for first, NULL_LID for following For each column DRDA TYPE LENGTH OVERRIDE For numeric/decimal types PRECISON SCALE otherwise LENGTH or DISPLAY_WIDTH
private  void writeSQLDXGRP(java.sql.ResultSetMetaData rsmeta, EmbedParameterSetMetaData pmeta, int jdbcElemNum, boolean rtnOutput)
           
private  void writeSQLERRRM(int severity)
          Write SQLERRRM Instance Variables SVRCOD - Severity Code - required
private  void writeSQLNUMGRP(java.sql.SQLException nextException)
          writeSQLNUMGRP: Writes SQLNUMGRP : FDOCA EARLY GROUP SQL Number of Elements Group Description FORMAT FOR ALL SQLAM LEVELS SQLNUM; DRDA TYPE I2; ENVLID 0x04; Length Override 2
private  void writeSQLNUMROW(java.sql.SQLException nextException)
          writeSQLNUMROW: Writes SQLNUMROW : FDOCA EARLY ROW SQL Number of Elements Row Description FORMAT FOR SQLAM LEVELS SQLNUMGRP; GROUP LID 0x58; ELEMENT TAKEN 0(all); REP FACTOR 1
private  void writeSQLRSLRD(DRDAStatement stmt)
          Write SQLRSLRD - result set reply data
private  void writeSQLUDTGRP(java.sql.ResultSetMetaData rsmeta, EmbedParameterSetMetaData pmeta, int jdbcElemNum, boolean rtnOutput)
           
private  void writeTYPDEFOVR()
           
private  void writeVCMorVCS(java.lang.String s)
          Write variable character mixed byte or single byte The preference is to write mixed byte if it is defined for the server, since that is our default and we don't allow it to be changed, we always write mixed byte.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

leftBrace

private static final java.lang.String leftBrace
See Also:
Constant Field Values

rightBrace

private static final java.lang.String rightBrace
See Also:
Constant Field Values

NULL_VALUE

private static final byte NULL_VALUE
See Also:
Constant Field Values

SYNTAX_ERR

private static final java.lang.String SYNTAX_ERR
See Also:
Constant Field Values

MGRLVL_3

private static final int MGRLVL_3
See Also:
Constant Field Values

MGRLVL_4

private static final int MGRLVL_4
See Also:
Constant Field Values

MGRLVL_5

private static final int MGRLVL_5
See Also:
Constant Field Values

MGRLVL_6

private static final int MGRLVL_6
See Also:
Constant Field Values

MGRLVL_7

private static final int MGRLVL_7
See Also:
Constant Field Values

COMMIT

private static final int COMMIT
See Also:
Constant Field Values

ROLLBACK

private static final int ROLLBACK
See Also:
Constant Field Values

ccsidManager

protected CcsidManager ccsidManager

correlationID

private int correlationID

sockis

private java.io.InputStream sockis

sockos

private java.io.OutputStream sockos

reader

private DDMReader reader

writer

private DDMWriter writer

xaProto

private DRDAXAProtocol xaProto

ACCRDB_REQUIRED

private static int[] ACCRDB_REQUIRED

MAX_REQUIRED_LEN

private static int MAX_REQUIRED_LEN

currentRequiredLength

private int currentRequiredLength

required

private int[] required

server

private NetworkServerControlImpl server

session

private Session session

timeSlice

private long timeSlice

timeSliceSync

private java.lang.Object timeSliceSync

logConnections

private boolean logConnections

sendWarningsOnCNTQRY

private boolean sendWarningsOnCNTQRY

logConnectionsSync

private java.lang.Object logConnectionsSync

close

private boolean close

closeSync

private java.lang.Object closeSync

logStream

private static HeaderPrintWriter logStream

appRequester

private AppRequester appRequester

database

private Database database

sqlamLevel

private int sqlamLevel

unknownManagers

private java.util.Vector unknownManagers

knownManagers

private java.util.Vector knownManagers

errorManagers

private java.util.Vector errorManagers

errorManagersLevel

private java.util.Vector errorManagersLevel

databaseAccessException

private java.sql.SQLException databaseAccessException

rdbnam

private java.lang.String rdbnam

rdbcolid

private java.lang.String rdbcolid

pkgid

private java.lang.String pkgid

pkgcnstknStr

private java.lang.String pkgcnstknStr

secnumber

private int secnumber

decryptionManager

private static DecryptionManager decryptionManager

myPublicKey

private byte[] myPublicKey

SQLERRMC_TOKEN_DELIMITER

private static java.lang.String SQLERRMC_TOKEN_DELIMITER
SQLERRMC_TOKEN_DELIMITER separates message argument tokens


SQLERRMC_MESSAGE_DELIMITER

private static java.lang.String SQLERRMC_MESSAGE_DELIMITER
SQLERRMC_MESSAGE_DELIMITER When message argument tokes are sent, this value separates the tokens for mulitiple error messages


SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER

private static java.lang.String SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER
SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER, When full message text is sent for severe errors. This value separates the messages.

Constructor Detail

DRDAConnThread

public DRDAConnThread(Session session,
                      NetworkServerControlImpl server,
                      long timeSlice,
                      boolean logConnections)
Create a new Thread for processing session requests

Parameters:
session - Session requesting processing
server - Server starting thread
timeSlice - timeSlice for thread
logConnections -
Method Detail

run

public void run()
Main routine for thread, loops until the thread is closed Gets a session, does work for the session


getInputStream

protected java.io.InputStream getInputStream()
Get input stream

Returns:
input stream

getOutputStream

protected java.io.OutputStream getOutputStream()
Get output stream

Returns:
output stream

getReader

protected DDMReader getReader()
get DDMReader

Returns:
DDMReader for this thread

getWriter

protected DDMWriter getWriter()
get DDMWriter

Returns:
DDMWriter for this thread

getCorrelationID

protected int getCorrelationID()
Get correlation id

Returns:
correlation id

getSession

protected Session getSession()
Get session we are working on

Returns:
session

getDatabase

protected Database getDatabase()
Get Database we are working on

Returns:
database

getServer

protected NetworkServerControlImpl getServer()
Get server

Returns:
server

getCrrtkn

protected byte[] getCrrtkn()
Get correlation token

Returns:
crrtkn

getDbName

protected java.lang.String getDbName()
Get database name

Returns:
database name

close

protected void close()
Close DRDA connection thread


setLogConnections

protected void setLogConnections(boolean value)
Set logging of connections

Parameters:
value - value to set for logging connections

setTimeSlice

protected void setTimeSlice(long value)
Set time slice value

Parameters:
value - new value for time slice

markCommunicationsFailure

protected void markCommunicationsFailure(java.lang.String arg1,
                                         java.lang.String arg2,
                                         java.lang.String arg3,
                                         java.lang.String arg4)
                                  throws DRDAProtocolException
Indicate a communications failure

Parameters:
arg1 - - info about the communications failure
arg2 - - info about the communications failure
arg3 - - info about the communications failure
arg4 - - info about the communications failure
Throws:
DRDAProtocolException - disconnect exception always thrown

throwSyntaxrm

protected void throwSyntaxrm(int errcd,
                             int cpArg)
                      throws DRDAProtocolException
Syntax error

Parameters:
errcd - Error code
cpArg - code point value
Throws:
DRDAProtocolException

agentError

protected void agentError(java.lang.String msg)
                   throws DRDAProtocolException
Agent error - something very bad happened

Parameters:
msg - Message describing error
Throws:
DRDAProtocolException - newAgentError always thrown

missingCodePoint

protected void missingCodePoint(int codePoint)
                         throws DRDAProtocolException
Missing code point

Parameters:
codePoint - code point value
Throws:
DRDAProtocolException

println2Log

protected static void println2Log(java.lang.String dbname,
                                  java.lang.String drdaID,
                                  java.lang.String msg)
Print a line to the DB2j log

Parameters:
dbname - database name
drdaID - DRDA identifier
msg - message

writeRDBNAM

protected void writeRDBNAM(java.lang.String rdbnam)
                    throws DRDAProtocolException
Write RDBNAM

Parameters:
rdbnam - database name
Throws:
DRDAProtocolException

initialize

private void initialize()
Initialize class


initializeForSession

private void initializeForSession()
Initialize for a new session


sessionInitialState

private void sessionInitialState()
                          throws java.lang.Exception
In initial state for a session, determine whether this is a command session or a DRDA protocol session. A command session is for changing the configuration of the Net server, e.g., turning tracing on If it is a command session, process the command and close the session. If it is a DRDA session, exchange server attributes and change session state.

Throws:
java.lang.Exception

processCommands

private void processCommands()
                      throws DRDAProtocolException
Process DRDA commands we can receive once server attributes have been exchanged.

Throws:
DRDAProtocolException

errorInChain

private void errorInChain(java.sql.SQLException e)
                   throws DRDAProtocolException
If there's a severe error in the DDM chain, and if the header indicates "terminate chain on error", we stop processing further commands in the chain nor do we send any reply for them. In accordance to this, a SQLERRRM message indicating the severe error must have been sent! (otherwise application requestor, such as JCC, would not terminate the receiving of chain replies.) Each DRDA command is processed independently. DRDA defines no interdependencies across chained commands. A command is processed the same when received within a set of chained commands or received separately. The chaining was originally defined as a way to save network costs.

Parameters:
e - the SQLException raised
Throws:
DRDAProtocolException

exchangeServerAttributes

private void exchangeServerAttributes()
                               throws DRDAProtocolException
Exchange server attributes with application requester

Throws:
DRDAProtocolException

parseDRDAConnection

private boolean parseDRDAConnection()
                             throws DRDAProtocolException
Throws:
DRDAProtocolException

writeRDBfailure

private void writeRDBfailure(int codePoint)
                      throws DRDAProtocolException
Write RDB Failure Instance Variables SVRCOD - Severity Code - required RDBNAM - Relational Database name - required SRVDGN - Server Diagnostics - optional (not sent for now)

Parameters:
codePoint - codepoint of failure
Throws:
DRDAProtocolException

getRdbAccessErrorCodePoint

private int getRdbAccessErrorCodePoint()

verifyUserIdPassword

private int verifyUserIdPassword()
                          throws DRDAProtocolException
Verify userId and password Username and password is verified by making a connection to the database

Returns:
security check code, 0 is O.K.
Throws:
DRDAProtocolException

getConnFromDatabaseName

private int getConnFromDatabaseName()
                             throws DRDAProtocolException
Get connection from a database name Username and password is verified by making a connection to the database

Returns:
security check code, 0 is O.K.
Throws:
DRDAProtocolException

parseEXCSAT

private void parseEXCSAT()
                  throws DRDAProtocolException
Parses EXCSAT (Exchange Server Attributes) Instance variables EXTNAM(External Name) - optional MGRLVLLS(Manager Levels) - optional SPVNAM(Supervisor Name) - optional SRVCLSNM(Server Class Name) - optional SRVNAM(Server Name) - optional, ignorable SRVRLSLV(Server Product Release Level) - optional, ignorable

Throws:
DRDAProtocolException

parseEXCSAT2

private void parseEXCSAT2()
                   throws DRDAProtocolException
Parses EXCSAT2 (Exchange Server Attributes) Instance variables EXTNAM(External Name) - optional MGRLVLLS(Manager Levels) - optional SPVNAM(Supervisor Name) - optional SRVCLSNM(Server Class Name) - optional SRVNAM(Server Name) - optional, ignorable SRVRLSLV(Server Product Release Level) - optional, ignorable

Throws:
DRDAProtocolException - This parses a second occurrence of an EXCSAT command The target must ignore the values for extnam, srvclsnm, srvnam and srvrlslv. I am also going to ignore spvnam since it should be null anyway. Only new managers can be added.

parseMGRLVLLS

private void parseMGRLVLLS(int time)
                    throws DRDAProtocolException
Parse manager levels Instance variables MGRLVL - repeatable, required CODEPOINT CCSIDMGR - CCSID Manager CMNAPPC - LU 6.2 Conversational Communications Manager CMNSYNCPT - SNA LU 6.2 SyncPoint Conversational Communications Manager CMNTCPIP - TCP/IP Communication Manager DICTIONARY - Dictionary RDB - Relational Database RSYNCMGR - Resynchronization Manager SECMGR - Security Manager SQLAM - SQL Application Manager SUPERVISOR - Supervisor SYNCPTMGR - Sync Point Manager VALUE On the second appearance of this codepoint, it can only add managers

Parameters:
time - 1 for first time this is seen, 2 for subsequent ones
Throws:
DRDAProtocolException

writeEXCSATRD

private void writeEXCSATRD()
                    throws DRDAProtocolException
Write reply to EXCSAT command Instance Variables EXTNAM - External Name (optional) MGRLVLLS - Manager Level List (optional) SRVCLSNM - Server Class Name (optional) - used by JCC SRVNAM - Server Name (optional) SRVRLSLV - Server Product Release Level (optional)

Throws:
DRDAProtocolException

writeMGRLEVELS

private void writeMGRLEVELS()
                     throws DRDAProtocolException
Write manager levels The target server must not provide information for any target managers unless the source explicitly requests it. For each manager class, if the target server's support level is greater than or equal to the source server's level, then the source server's level is returned for that class if the target server can operate at the source's level; otherwise a level 0 is returned. If the target server's support level is less than the source server's level, the target server's level is returned for that class. If the target server does not recognize the code point of a manager class or does not support that class, it returns a level of 0. The target server then waits for the next command or for the source server to terminate communications. When the source server receives EXCSATRD, it must compare each of the entries in the mgrlvlls parameter it received to the corresponding entries in the mgrlvlls parameter it sent. If any level mismatches, the source server must decide whether it can use or adjust to the lower level of target support for that manager class. There are no architectural criteria for making this decision. The source server can terminate communications or continue at the target servers level of support. It can also attempt to use whatever commands its user requests while receiving error reply messages for real functional mismatches. The manager levels the source server specifies or the target server returns must be compatible with the manager-level dependencies of the specified manangers. Incompatible manager levels cannot be specified. Instance variables MGRLVL - repeatable, required CODEPOINT CCSIDMGR - CCSID Manager CMNAPPC - LU 6.2 Conversational Communications Manager CMNSYNCPT - SNA LU 6.2 SyncPoint Conversational Communications Manager CMNTCPIP - TCP/IP Communication Manager DICTIONARY - Dictionary RDB - Relational Database RSYNCMGR - Resynchronization Manager SECMGR - Security Manager SQLAM - SQL Application Manager SUPERVISOR - Supervisor SYNCPTMGR - Sync Point Manager XAMGR - XA manager VALUE

Throws:
DRDAProtocolException

parseACCSEC

private int parseACCSEC()
                 throws DRDAProtocolException
Parse Access Security If the target server supports the SECMEC requested by the application requester then a single value is returned and it is identical to the SECMEC value in the ACCSEC command. If the target server does not support the SECMEC requested, then one or more values are returned and the application requester must choose one of these values for the security mechanism. We currently support - user id and password (default for JCC) - encrypted user id and password Instance variables SECMGRNM - security manager name - optional SECMEC - security mechanism - required RDBNAM - relational database name - optional SECTKN - security token - optional, (required if sec mech. needs it)

Returns:
security check code - 0 if everything O.K.
Throws:
DRDAProtocolException

parseOPNQRY

private java.lang.String parseOPNQRY()
                              throws DRDAProtocolException,
                                     java.sql.SQLException
Parse OPNQRY Instance Variables RDBNAM - relational database name - optional PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required QRYBLKSZ - Query Block Size - required QRYBLKCTL - Query Block Protocol Control - optional MAXBLKEXT - Maximum Number of Extra Blocks - optional - default value 0 OUTOVROPT - Output Override Option QRYROWSET - Query Rowset Size - optional - level 7 MONITOR - Monitor events - optional.

Returns:
package name consistency token
Throws:
DRDAProtocolException
java.sql.SQLException

parseOPNQRYobjects

private void parseOPNQRYobjects(DRDAStatement stmt)
                         throws DRDAProtocolException,
                                java.sql.SQLException
Parse OPNQRY objects Objects TYPDEFNAM - Data type definition name - optional TYPDEFOVR - Type defintion overrides - optional SQLDTA- SQL Program Variable Data - optional If TYPDEFNAM and TYPDEFOVR are supplied, they apply to the objects sent with the statement. Once the statement is over, the default values sent in the ACCRDB are once again in effect. If no values are supplied, the values sent in the ACCRDB are used. Objects may follow in one DSS or in several DSS chained together.

Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

parseOUTOVROPT

private int parseOUTOVROPT()
                    throws DRDAProtocolException
Parse OUTOVROPT - this indicates whether output description can be overridden on just the first CNTQRY or on any CNTQRY

Returns:
output override option
Throws:
DRDAProtocolException

parseQRYBLKSZ

private int parseQRYBLKSZ()
                   throws DRDAProtocolException
Parse QRYBLSZ - this gives the maximum size of the query blocks that can be returned to the requester

Returns:
query block size
Throws:
DRDAProtocolException

parseQRYROWSET

private int parseQRYROWSET(int minVal)
                    throws DRDAProtocolException
Parse QRYROWSET - this is the number of rows to return

Parameters:
minVal - - minimum value
Returns:
query row set size
Throws:
DRDAProtocolException

parseQRYCLSIMP

private int parseQRYCLSIMP()
                    throws DRDAProtocolException
Parse a QRYCLSIMP - Implicitly close non-scrollable cursor after end of data.

Returns:
true to close on end of data
Throws:
DRDAProtocolException

parseQRYCLSRLS

private int parseQRYCLSRLS()
                    throws DRDAProtocolException
Throws:
DRDAProtocolException

parseQRYOPTVAL

private int parseQRYOPTVAL()
                    throws DRDAProtocolException
Throws:
DRDAProtocolException

writeQRYPOPRM

private void writeQRYPOPRM()
                    throws DRDAProtocolException
Write a QRYPOPRM - Query Previously opened Instance Variables SVRCOD - Severity Code - required - 8 ERROR RDBNAM - Relational Database Name - required PKGNAMCSN - RDB Package Name, Consistency Token, and Section Number - required

Throws:
DRDAProtocolException

writeQRYNOPRM

private void writeQRYNOPRM(int svrCod)
                    throws DRDAProtocolException
Write a QRYNOPRM - Query Not Opened Instance Variables SVRCOD - Severity Code - required - 4 Warning 8 ERROR RDBNAM - Relational Database Name - required PKGNAMCSN - RDB Package Name, Consistency Token, and Section Number - required

Parameters:
svrCod - Severity Code
Throws:
DRDAProtocolException

writeOPNQFLRM

private void writeOPNQFLRM(java.sql.SQLException e)
                    throws DRDAProtocolException
Write a OPNQFLRM - Open Query Failure Instance Variables SVRCOD - Severity Code - required - 8 ERROR RDBNAM - Relational Database Name - required

Parameters:
e - Exception describing failure
Throws:
DRDAProtocolException

writePKGNAMCSN

private void writePKGNAMCSN(java.lang.String pkgcnstknStr)
                     throws DRDAProtocolException
Write PKGNAMCSN Instance Variables NAMESYMDR - database name - not validated RDBCOLID - RDB Collection Identifier PKGID - RDB Package Identifier PKGCNSTKN - RDB Package Consistency Token PKGSN - RDB Package Section Number There are two possible formats, fixed and extended which includes length information for the strings

Throws:
throws - DRDAProtocolException
DRDAProtocolException

writePKGNAMCSN

private void writePKGNAMCSN()
                     throws DRDAProtocolException
Throws:
DRDAProtocolException

parseCNTQRY

private DRDAStatement parseCNTQRY()
                           throws DRDAProtocolException,
                                  java.sql.SQLException
Parse CNTQRY - Continue Query Instance Variables RDBNAM - Relational Database Name - optional PKGNAMCSN - RDB Package Name, Consistency Token, and Section Number - required QRYBLKSZ - Query Block Size - required QRYRELSCR - Query Relative Scrolling Action - optional QRYSCRORN - Query Scroll Orientation - optional - level 7 QRYROWNBR - Query Row Number - optional QRYROWSNS - Query Row Sensitivity - optional - level 7 QRYBLKRST - Query Block Reset - optional - level 7 QRYRTNDTA - Query Returns Data - optional - level 7 QRYROWSET - Query Rowset Size - optional - level 7 QRYRFRTBL - Query Refresh Answer Set Table - optional NBRROW - Number of Fetch or Insert Rows - optional MAXBLKEXT - Maximum number of extra blocks - optional RTNEXTDTA - Return of EXTDTA Option - optional MONITOR - Monitor events - optional.

Returns:
DRDAStatement we are continuing
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

skipRemainder

private void skipRemainder(boolean onlySkipSameIds)
                    throws DRDAProtocolException
Skip remainder of current DSS and all chained DSS'es

Parameters:
onlySkipSameIds - True if we _only_ want to skip DSS'es that are chained with the SAME id as the current DSS. False means skip ALL chained DSSes, whether they're chained with same or different ids.
Throws:
DRDAProtocolException

parseCNTQRYobjects

private void parseCNTQRYobjects(DRDAStatement stmt)
                         throws DRDAProtocolException,
                                java.sql.SQLException
Parse CNTQRY objects Instance Variables OUTOVR - Output Override Descriptor - optional

Parameters:
stmt - DRDA statement we are working on
Throws:
DRDAProtocolException
java.sql.SQLException

parseOUTOVR

private void parseOUTOVR(DRDAStatement stmt)
                  throws DRDAProtocolException,
                         java.sql.SQLException
Parse OUTOVR - Output Override Descriptor This specifies the output format for data to be returned as output to a SQL statement or as output from a query.

Parameters:
stmt - DRDA statement this applies to
Throws:
DRDAProtocolException
java.sql.SQLException

writeOPNQRYRM

private void writeOPNQRYRM(boolean isDssObject,
                           DRDAStatement stmt)
                    throws DRDAProtocolException,
                           java.sql.SQLException
Write OPNQRYRM - Open Query Complete Instance Variables SVRCOD - Severity Code - required QRYPRCTYP - Query Protocol Type - required SQLCSRHLD - Hold Cursor Position - optional QRYATTSCR - Query Attribute for Scrollability - optional - level 7 QRYATTSNS - Query Attribute for Sensitivity - optional - level 7 QRYATTUPD - Query Attribute for Updatability -optional - level 7 QRYINSID - Query Instance Identifier - required - level 7 SRVDGN - Server Diagnostic Information - optional

Parameters:
isDssObject - - return as a DSS object (part of a reply)
stmt - - DRDA statement we are processing
Throws:
DRDAProtocolException
java.sql.SQLException

writeENDQRYRM

private void writeENDQRYRM(int svrCod)
                    throws DRDAProtocolException
Write ENDQRYRM - query process has terminated in such a manner that the query or result set is now closed. It cannot be resumed with the CNTQRY command or closed with the CLSQRY command

Parameters:
svrCod - Severity code - WARNING or ERROR
Throws:
DRDAProtocolException

writeABNUOWRM

private void writeABNUOWRM()
                    throws DRDAProtocolException
Write ABNUOWRM - query process has terminated in an error condition such as deadlock or lock timeout. Severity code is always error * @exception DRDAProtocolException

Throws:
DRDAProtocolException

parseRDBNAM

private java.lang.String parseRDBNAM()
                              throws DRDAProtocolException
Parse database name

Returns:
database name
Throws:
DRDAProtocolException

writeACCSECRD

private void writeACCSECRD(int securityCheckCode)
                    throws DRDAProtocolException
Write ACCSECRD If the security mechanism is known, we just send it back along with the security token if encryption is going to be used. If the security mechanism is not known, we send a list of the ones we know. Instance Variables SECMEC - security mechanism - required SECTKN - security token - optional (required if security mechanism uses encryption) SECCHKCD - security check code - error occurred in processing ACCSEC

Parameters:
securityCheckCode -
Throws:
DRDAProtocolException

parseSECCHK

private int parseSECCHK()
                 throws DRDAProtocolException
Parse security check Instance Variables SECMGRNM - security manager name - optional, ignorable SECMEC - security mechanism - required SECTKN - security token - optional, (required if encryption used) PASSWORD - password - optional, (required if security mechanism uses it) NEWPASSWORD - new password - optional, (required if sec mech. uses it) USRID - user id - optional, (required if sec mec. uses it) RDBNAM - database name - optional (required if databases can have own sec.)

Returns:
security check code
Throws:
DRDAProtocolException

writeSECCHKRM

private void writeSECCHKRM(int securityCheckCode)
                    throws DRDAProtocolException
Write security check reply Instance variables SVRCOD - serverity code - required SECCHKCD - security check code - required SECTKN - security token - optional, ignorable SVCERRNO - security service error number SRVDGN - Server Diagnostic Information

Throws:
DRDAProtocolException

svrcodFromSecchkcd

private int svrcodFromSecchkcd(int securityCheckCode)
Calculate SVRCOD value from SECCHKCD

Parameters:
securityCheckCode -
Returns:
SVRCOD value

parseACCRDB

private int parseACCRDB()
                 throws DRDAProtocolException
Parse access RDB Instance variables RDBACCCL - RDB Access Manager Class - required must be SQLAM CRRTKN - Correlation Token - required RDBNAM - Relational database name -required PRDID - Product specific identifier - required TYPDEFNAM - Data Type Definition Name -required TYPDEFOVR - Type definition overrides -required RDBALWUPD - RDB Allow Updates optional PRDDTA - Product Specific Data - optional - ignorable STTDECDEL - Statement Decimal Delimiter - optional STTSTRDEL - Statement String Delimiter - optional TRGDFTRT - Target Default Value Return - optional

Returns:
severity code
Throws:
DRDAProtocolException

parseTYPDEFNAM

private java.lang.String parseTYPDEFNAM()
                                 throws DRDAProtocolException
Parse TYPDEFNAM

Returns:
typdefnam
Throws:
DRDAProtocolException

setStmtOrDbByteOrder

private void setStmtOrDbByteOrder(boolean setDatabase,
                                  DRDAStatement stmt,
                                  java.lang.String typDefNam)
Set a statement or the database' byte order, depending on the arguments

Parameters:
setDatabase - if true, set database' byte order, otherwise set statement's
stmt - DRDAStatement, used when setDatabase is false
typDefNam - TYPDEFNAM value

writeACCRDBRM

private void writeACCRDBRM(int svrcod)
                    throws DRDAProtocolException
Write Access to RDB Completed Instance Variables SVRCOD - severity code - 0 info, 4 warning -required PRDID - product specific identifier -required TYPDEFNAM - type definition name -required TYPDEFOVR - type definition overrides - required RDBINTTKN - token which can be used to interrupt DDM commands - optional CRRTKN - correlation token - only returned if we didn't get one from requester SRVDGN - server diagnostic information - optional PKGDFTCST - package default character subtype - optional USRID - User ID at the target system - optional SRVLST - Server List

Throws:
DRDAProtocolException

writeTYPDEFOVR

private void writeTYPDEFOVR()
                     throws DRDAProtocolException
Throws:
DRDAProtocolException

parseTYPDEFOVR

private void parseTYPDEFOVR(DRDAStatement st)
                     throws DRDAProtocolException
Parse Type Defintion Overrides TYPDEF Overrides specifies the Coded Character SET Identifiers (CCSIDs) that are in a named TYPDEF. Instance Variables CCSIDSBC - CCSID for Single-Byte - optional CCSIDDBC - CCSID for Double-Byte - optional CCSIDMBC - CCSID for Mixed-byte characters -optional

Parameters:
st - Statement this TYPDEFOVR applies to
Throws:
DRDAProtocolException

parsePRPSQLSTT

private int parsePRPSQLSTT()
                    throws DRDAProtocolException,
                           java.sql.SQLException
Parse PRPSQLSTT - Prepare SQL Statement Instance Variables RDBNAM - Relational Database Name - optional PKGNAMCAN - RDB Package Name, Consistency Token, and Section Number - required RTNSQLDA - Return SQL Descriptor Area - optional MONITOR - Monitor events - optional.

Returns:
return 0 - don't return sqlda, 1 - return input sqlda, 2 - return output sqlda
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

parsePRPSQLSTTobjects

private java.lang.String parsePRPSQLSTTobjects(DRDAStatement stmt)
                                        throws DRDAProtocolException,
                                               java.sql.SQLException
Parse PRPSQLSTT objects Objects TYPDEFNAM - Data type definition name - optional TYPDEFOVR - Type defintion overrides - optional SQLSTT - SQL Statement required SQLATTR - Cursor attributes on prepare - optional - level 7 If TYPDEFNAM and TYPDEFOVR are supplied, they apply to the objects sent with the statement. Once the statement is over, the default values sent in the ACCRDB are once again in effect. If no values are supplied, the values sent in the ACCRDB are used. Objects may follow in one DSS or in several DSS chained together.

Returns:
SQL statement
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

parseTYPSQLDA

private boolean parseTYPSQLDA()
                       throws DRDAProtocolException
Parse TYPSQLDA - Type of the SQL Descriptor Area

Returns:
true if for output; false otherwise
Throws:
DRDAProtocolException

parseSQLATTR

protected void parseSQLATTR(DRDAStatement stmt)
                     throws DRDAProtocolException
Parse SQLATTR - Cursor attributes on prepare This is an encoded string. Can have combination of following, eg INSENSITIVE SCROLL WITH HOLD Possible strings are SENSITIVE DYNAMIC SCROLL [FOR UPDATE] SENSITIVE STATIC SCROLL [FOR UPDATE] INSENSITIVE SCROLL FOR UPDATE WITH HOLD

Parameters:
stmt - DRDAStatement
Throws:
DRDAProtocolException

parseDSCSQLSTT

private boolean parseDSCSQLSTT()
                        throws DRDAProtocolException,
                               java.sql.SQLException
Parse DSCSQLSTT - Describe SQL Statement previously prepared Instance Variables TYPSQLDA - sqlda type expected (output or input) RDBNAM - relational database name - optional PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required MONITOR - Monitor events - optional.

Returns:
expect "output sqlda" or not
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

parseEXCSQLSTT

private void parseEXCSQLSTT()
                     throws DRDAProtocolException,
                            java.sql.SQLException
Parse EXCSQLSTT - Execute non-cursor SQL Statement previously prepared Instance Variables RDBNAM - relational database name - optional PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required OUTEXP - Output expected NBRROW - Number of rows to be inserted if it's an insert PRCNAM - procedure name if specified by host variable, not needed for Cloudscape QRYBLKSZ - query block size MAXRSLCNT - max resultset count MAXBLKEXT - Max number of extra blocks RSLSETFLG - resultset flag RDBCMTOK - RDB Commit Allowed - optional OUTOVROPT - output override option QRYROWSET - Query Rowset Size - Level 7 MONITOR - Monitor events - optional.

Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

parseRDBCMTOK

private void parseRDBCMTOK()
                    throws DRDAProtocolException
Parse RDBCMTOK - tells the database whether to allow commits or rollbacks to be executed as part of the command Since we don't have a SQL commit or rollback command, we will just ignore this for now

Throws:
DRDAProtocolException

parseEXCSQLSTTobjects

private void parseEXCSQLSTTobjects(DRDAStatement stmt)
                            throws DRDAProtocolException,
                                   java.sql.SQLException
Parse EXCSQLSTT command objects Command Objects TYPDEFNAM - Data Type Definition Name - optional TYPDEFOVR - TYPDEF Overrides -optional SQLDTA - optional, variable data, specified if prpared statement has input parameters EXTDTA - optional, externalized FD:OCA data OUTOVR - output override descriptor, not allowed for stored procedure calls If TYPDEFNAM and TYPDEFOVR are supplied, they apply to the objects sent with the statement. Once the statement is over, the default values sent in the ACCRDB are once again in effect. If no values are supplied, the values sent in the ACCRDB are used. Objects may follow in one DSS or in several DSS chained together.

Parameters:
stmt - the DRDAStatement to execute
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

writeSQLCINRD

private void writeSQLCINRD(DRDAStatement stmt)
                    throws DRDAProtocolException,
                           java.sql.SQLException
Write SQLCINRD - result set column information

Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

writeSQLRSLRD

private void writeSQLRSLRD(DRDAStatement stmt)
                    throws DRDAProtocolException,
                           java.sql.SQLException
Write SQLRSLRD - result set reply data

Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

writeRSLSETRM

private void writeRSLSETRM(DRDAStatement stmt)
                    throws DRDAProtocolException,
                           java.sql.SQLException
Write RSLSETRM Instance variables SVRCOD - Severity code - Information only - required PKGSNLST - list of PKGNAMCSN -required SRVDGN - Server Diagnostic Information -optional

Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

parseSQLDTA

private void parseSQLDTA(DRDAStatement stmt)
                  throws DRDAProtocolException,
                         java.sql.SQLException
Parse SQLDTA - SQL program variable data and handle exception.

Throws:
DRDAProtocolException
java.sql.SQLException
See Also:
parseSQLDTA_work(org.apache.derby.impl.drda.DRDAStatement)

parseSQLDTA_work

private void parseSQLDTA_work(DRDAStatement stmt)
                       throws DRDAProtocolException,
                              java.sql.SQLException
Parse SQLDTA - SQL program variable data Instance Variables FDODSC - FD:OCA data descriptor - required FDODTA - FD:OCA data - optional

Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

getByteOrder

private int getByteOrder()

readAndSetParams

private java.util.ArrayList readAndSetParams(int i,
                                             DRDAStatement stmt,
                                             int drdaType,
                                             EmbedParameterSetMetaData pmeta,
                                             java.util.ArrayList paramExtPositions,
                                             int paramLenNumBytes)
                                      throws DRDAProtocolException,
                                             java.sql.SQLException
Read different types of input parameters and set them in PreparedStatement

Parameters:
i - index of the parameter
stmt - drda statement
drdaType - drda type of the parameter
pmeta - parameter meta data
paramExtPositions - ArrayList of parameters with extdta
paramLenNumBytes - Number of bytes for encoding LOB Length
Returns:
updated paramExtPositions
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

readLobLength

private long readLobLength(int extLenIndicator)
                    throws DRDAProtocolException
Throws:
DRDAProtocolException

readAndSetAllExtParams

private void readAndSetAllExtParams(DRDAStatement stmt)
                             throws java.sql.SQLException,
                                    DRDAProtocolException
Throws:
java.sql.SQLException
DRDAProtocolException

readAndSetExtParam

private void readAndSetExtParam(int i,
                                DRDAStatement stmt,
                                int drdaType,
                                int extLen)
                         throws DRDAProtocolException,
                                java.sql.SQLException
Read different types of input parameters and set them in PreparedStatement

Parameters:
i - index of the parameter
stmt - associated ps
drdaType - drda type of the parameter
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

parseEXCSQLIMM

private int parseEXCSQLIMM()
                    throws DRDAProtocolException,
                           java.sql.SQLException
Parse EXCSQLIMM - Execute Immediate Statement Instance Variables RDBNAM - relational database name - optional PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required RDBCMTOK - RDB Commit Allowed - optional MONITOR - Monitor Events - optional Command Objects TYPDEFNAM - Data Type Definition Name - optional TYPDEFOVR - TYPDEF Overrides -optional SQLSTT - SQL Statement -required

Returns:
update count
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

parseEXCSQLSET

private boolean parseEXCSQLSET()
                        throws DRDAProtocolException,
                               java.sql.SQLException
Parse EXCSQLSET - Execute Set SQL Environment Instance Variables RDBNAM - relational database name - optional PKGNAMCT - RDB Package Name, Consistency Token - optional MONITOR - Monitor Events - optional Command Objects TYPDEFNAM - Data Type Definition Name - required TYPDEFOVR - TYPDEF Overrides - required SQLSTT - SQL Statement - required (at least one; may be more)

Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

parseEXECSQLIMMobjects

private java.lang.String parseEXECSQLIMMobjects()
                                         throws DRDAProtocolException,
                                                java.sql.SQLException
Parse EXCSQLIMM objects Objects TYPDEFNAM - Data type definition name - optional TYPDEFOVR - Type defintion overrides SQLSTT - SQL Statement required If TYPDEFNAM and TYPDEFOVR are supplied, they apply to the objects sent with the statement. Once the statement is over, the default values sent in the ACCRDB are once again in effect. If no values are supplied, the values sent in the ACCRDB are used. Objects may follow in one DSS or in several DSS chained together.

Returns:
SQL Statement
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

parseEXCSQLSETobjects

private void parseEXCSQLSETobjects()
                            throws DRDAProtocolException,
                                   java.sql.SQLException
Parse EXCSQLSET objects Objects TYPDEFNAM - Data type definition name - optional TYPDEFOVR - Type defintion overrides - optional SQLSTT - SQL Statement - required (a list of at least one) Objects may follow in one DSS or in several DSS chained together.

Returns:
Count of updated rows.
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

canIgnoreStmt

private boolean canIgnoreStmt(java.lang.String stmt)

writeRDBUPDRM

private void writeRDBUPDRM()
                    throws DRDAProtocolException
Write RDBUPDRM Instance variables SVRCOD - Severity code - Information only - required RDBNAM - Relational database name -required SRVDGN - Server Diagnostic Information -optional

Throws:
DRDAProtocolException

parsePKGNAMCT

private java.lang.String parsePKGNAMCT()
                                throws DRDAProtocolException
Throws:
DRDAProtocolException

parsePKGNAMCSN

private java.lang.String parsePKGNAMCSN()
                                 throws DRDAProtocolException
Parse PKGNAMCSN - RDB Package Name, Consistency Token, and Section Number Instance Variables NAMESYMDR - database name - not validated RDBCOLID - RDB Collection Identifier PKGID - RDB Package Identifier PKGCNSTKN - RDB Package Consistency Token PKGSN - RDB Package Section Number

Throws:
throws - DRDAProtocolException
DRDAProtocolException

parseSQLSTTDss

private java.lang.String parseSQLSTTDss()
                                 throws DRDAProtocolException
Parse SQLSTT Dss

Throws:
DRDAProtocolException

parseEncodedString

private java.lang.String parseEncodedString()
                                     throws DRDAProtocolException
Parse an encoded data string from the Application Requester

Returns:
string value
Throws:
DRDAProtocolException

parseVCMorVCS

private java.lang.String parseVCMorVCS()
                                throws DRDAProtocolException
Parse variable character mixed byte or variable character single byte Format I2 - VCM Length N bytes - VCM value I2 - VCS Length N bytes - VCS value Only 1 of VCM length or VCS length can be non-zero

Returns:
string value
Throws:
DRDAProtocolException

parseNOCMorNOCS

private java.lang.String parseNOCMorNOCS()
                                  throws DRDAProtocolException
Parse nullable character mixed byte or nullable character single byte Format 1 byte - null indicator I4 - mixed character length N bytes - mixed character string 1 byte - null indicator I4 - single character length N bytes - single character length string

Returns:
string value
Throws:
DRDAProtocolException

parseCcsidMBC

private java.lang.String parseCcsidMBC(int length)
                                throws DRDAProtocolException
Parse mixed character string

Returns:
string value
Throws:
DRDAProtocolException

parseCcsidSBC

private java.lang.String parseCcsidSBC(int length)
                                throws DRDAProtocolException
Parse single byte character string

Returns:
string value
Throws:
DRDAProtocolException

parseCLSQRY

private DRDAStatement parseCLSQRY()
                           throws DRDAProtocolException,
                                  java.sql.SQLException
Parse CLSQRY Instance Variables RDBNAM - relational database name - optional PKGNAMCSN - RDB Package Name, Consistency Token and Section Number - required QRYINSID - Query Instance Identifier - required - level 7 MONITOR - Monitor events - optional.

Returns:
DRDAstatement being closed
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

parseMONITOR

private void parseMONITOR()
                   throws DRDAProtocolException
Parse MONITOR DRDA spec says this is optional. Since we don't currently support it, we just ignore.

Throws:
DRDAProtocolException

writeSQLCARDs

private void writeSQLCARDs(java.sql.SQLException e,
                           int updateCount)
                    throws DRDAProtocolException
Throws:
DRDAProtocolException

writeSQLCARDs

private void writeSQLCARDs(java.sql.SQLException e,
                           int updateCount,
                           boolean sendSQLERRRM)
                    throws DRDAProtocolException
Throws:
DRDAProtocolException

getSqlCode

private int getSqlCode(int severity)

writeSQLCARD

private void writeSQLCARD(java.sql.SQLException e,
                          int severity,
                          int updateCount,
                          long rowCount)
                   throws DRDAProtocolException
Throws:
DRDAProtocolException

writeNullSQLCARDobject

private void writeNullSQLCARDobject()
                             throws DRDAProtocolException
Write a null SQLCARD as an object

Throws:
DRDAProtocolException

writeSQLERRRM

private void writeSQLERRRM(int severity)
                    throws DRDAProtocolException
Write SQLERRRM Instance Variables SVRCOD - Severity Code - required

Parameters:
severity - severity of error
Throws:
DRDAProtocolException

writeCMDCHKRM

private void writeCMDCHKRM(int severity)
                    throws DRDAProtocolException
Write CMDCHKRM Instance Variables SVRCOD - Severity Code - required

Parameters:
severity - severity of error
Throws:
DRDAProtocolException

getExceptionSeverity

private int getExceptionSeverity(java.sql.SQLException e)
Translate from Cloudscape exception severity to SVRCOD

Parameters:
e - SQLException

writeSQLCAGRP

private void writeSQLCAGRP(java.sql.SQLException e,
                           int sqlcode,
                           int updateCount,
                           long rowCount)
                    throws DRDAProtocolException
Write SQLCAGRP SQLCAGRP : FDOCA EARLY GROUP SQL Communcations Area Group Description FORMAT FOR SQLAM <= 6 SQLCODE; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLSTATE; DRDA TYPE FCS; ENVLID 0x30; Length Override 5 SQLERRPROC; DRDA TYPE FCS; ENVLID 0x30; Length Override 8 SQLCAXGRP; DRDA TYPE N-GDA; ENVLID 0x52; Length Override 0 FORMAT FOR SQLAM >= 7 SQLCODE; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLSTATE; DRDA TYPE FCS; ENVLID 0x30; Length Override 5 SQLERRPROC; DRDA TYPE FCS; ENVLID 0x30; Length Override 8 SQLCAXGRP; DRDA TYPE N-GDA; ENVLID 0x52; Length Override 0 SQLDIAGGRP; DRDA TYPE N-GDA; ENVLID 0x56; Length Override 0

Parameters:
e - SQLException encountered
sqlcode - sqlcode
Throws:
DRDAProtocolException

buildSqlerrmc

private java.lang.String buildSqlerrmc(java.sql.SQLException se)
Create error message or message argements to return to client. The SQLERRMC will normally be passed back to the server in a call to the SYSIBM.SQLCAMESSAGE but for severe exceptions the stored procedure call cannot be made. So for Severe messages we will just send the message text. This method will also truncate the value according the client capacity. CCC can only handle 70 characters.

Parameters:
se - SQLException to build SQLERRMC
Returns:
String which is either the message arguments to be passed to SYSIBM.SQLCAMESSAGE or just message text for severe errors.

buildPreformattedSqlerrmc

private java.lang.String buildPreformattedSqlerrmc(java.sql.SQLException se)
Build preformatted SQLException text for severe exceptions or SQLExceptions that are not EmbedSQLExceptions. Just send the message text localized to the server locale.

Parameters:
se - SQLException for which to build SQLERRMC
Returns:
preformated message text with messages separted by SQLERRMC_PREFORMATED_MESSAGE_DELIMITER

buildTokenizedSqlerrmc

private java.lang.String buildTokenizedSqlerrmc(EmbedSQLException se)
Build Tokenized SQLERRMC to just send the tokenized arguments to the client. for a Derby SQLException Message argument tokens are separated by SQLERRMC_TOKEN_DELIMITER Multiple messages are separated by SQLERRMC_MESSAGE_DELIMITER ...

Parameters:
se - SQLException to print

writeSQLCAXGRP

private void writeSQLCAXGRP(int updateCount,
                            long rowCount,
                            java.lang.String sqlerrmc,
                            java.sql.SQLException nextException)
                     throws DRDAProtocolException
Write SQLCAXGRP SQLCAXGRP : EARLY FDOCA GROUP SQL Communications Area Exceptions Group Description FORMAT FOR SQLAM <= 6 SQLRDBNME; DRDA TYPE FCS; ENVLID 0x30; Length Override 18 SQLERRD1; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD2; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD3; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD4; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD5; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD6; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLWARN0; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN1; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN2; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN3; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN4; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN5; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN6; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN7; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN8; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN9; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARNA; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLERRMSG_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 70 SQLERRMSG_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 70 FORMAT FOR SQLAM >= 7 SQLERRD1; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD2; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD3; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD4; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD5; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLERRD6; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLWARN0; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN1; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN2; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN3; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN4; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN5; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN6; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN7; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN8; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARN9; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLWARNA; DRDA TYPE FCS; ENVLID 0x30; Length Override 1 SQLRDBNAME; DRDA TYPE VCS; ENVLID 0x32; Length Override 255 SQLERRMSG_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 70 SQLERRMSG_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 70

Parameters:
nextException - SQLException encountered
sqlerrmc - sqlcode
Throws:
DRDAProtocolException

writeSQLCAERRWARN

private void writeSQLCAERRWARN(int updateCount,
                               long rowCount)
Write the ERR and WARN part of the SQLCA

Parameters:
updateCount -
rowCount -

writeSQLDIAGGRP

private void writeSQLDIAGGRP(java.sql.SQLException nextException)
                      throws DRDAProtocolException
Write SQLDIAGGRP: SQL Diagnostics Group Description - Identity 0xD1 Nullable Group SQLDIAGSTT; DRDA TYPE N-GDA; ENVLID 0xD3; Length Override 0 SQLDIAGCN; DRFA TYPE N-RLO; ENVLID 0xF6; Length Override 0 SQLDIAGCI; DRDA TYPE N-RLO; ENVLID 0xF5; Length Override 0

Throws:
DRDAProtocolException

writeSQLDIAGSTT

private void writeSQLDIAGSTT()
                      throws DRDAProtocolException
Throws:
DRDAProtocolException

writeSQLDIAGCI

private void writeSQLDIAGCI(java.sql.SQLException nextException)
                     throws DRDAProtocolException
writeSQLDIAGCI: SQL Diagnostics Condition Information Array - Identity 0xF5 SQLNUMROW; ROW LID 0x68; ELEMENT TAKEN 0(all); REP FACTOR 1 SQLDCIROW; ROW LID 0xE5; ELEMENT TAKEN 0(all); REP FACTOR 0(all)

Throws:
DRDAProtocolException

writeSQLNUMROW

private void writeSQLNUMROW(java.sql.SQLException nextException)
                     throws DRDAProtocolException
writeSQLNUMROW: Writes SQLNUMROW : FDOCA EARLY ROW SQL Number of Elements Row Description FORMAT FOR SQLAM LEVELS SQLNUMGRP; GROUP LID 0x58; ELEMENT TAKEN 0(all); REP FACTOR 1

Throws:
DRDAProtocolException

writeSQLNUMGRP

private void writeSQLNUMGRP(java.sql.SQLException nextException)
                     throws DRDAProtocolException
writeSQLNUMGRP: Writes SQLNUMGRP : FDOCA EARLY GROUP SQL Number of Elements Group Description FORMAT FOR ALL SQLAM LEVELS SQLNUM; DRDA TYPE I2; ENVLID 0x04; Length Override 2

Throws:
DRDAProtocolException

writeSQLDCROW

private void writeSQLDCROW(long rowNum,
                           int sqlCode,
                           java.lang.String sqlState,
                           java.lang.String dbname,
                           java.lang.String sqlerrmc)
                    throws DRDAProtocolException
writeSQLDCROW: SQL Diagnostics Condition Row - Identity 0xE5 SQLDCGRP; GROUP LID 0xD5; ELEMENT TAKEN 0(all); REP FACTOR 1

Throws:
DRDAProtocolException

writeSQLDCGRP

private void writeSQLDCGRP(long rowNum,
                           int sqlCode,
                           java.lang.String sqlState,
                           java.lang.String dbname,
                           java.lang.String sqlerrmc)
                    throws DRDAProtocolException
writeSQLDCGRP: SQL Diagnostics Condition Group Description SQLDCCODE; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCSTATE; DRDA TYPE FCS; ENVLID Ox30; Lengeh Override 5 SQLDCREASON; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCLINEN; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCROWN; DRDA TYPE FD; ENVLID 0x0E; Lengeh Override 31 SQLDCER01; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCER02; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCER03; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCER04; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCPART; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCPPOP; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLDCMSGID; DRDA TYPE FCS; ENVLID 0x30; Length Override 10 SQLDCMDE; DRDA TYPE FCS; ENVLID 0x30; Length Override 8 SQLDCPMOD; DRDA TYPE FCS; ENVLID 0x30; Length Override 5 SQLDCRDB; DRDA TYPE VCS; ENVLID 0x32; Length Override 255 SQLDCTOKS; DRDA TYPE N-RLO; ENVLID 0xF7; Length Override 0 SQLDCMSG_m; DRDA TYPE NVMC; ENVLID 0x3F; Length Override 32672 SQLDCMSG_S; DRDA TYPE NVCS; ENVLID 0x33; Length Override 32672 SQLDCCOLN_m; DRDA TYPE NVCM ; ENVLID 0x3F; Length Override 255 SQLDCCOLN_s; DRDA TYPE NVCS; ENVLID 0x33; Length Override 255 SQLDCCURN_m; DRDA TYPE NVCM; ENVLID 0x3F; Length Override 255 SQLDCCURN_s; DRDA TYPE NVCS; ENVLID 0x33; Length Override 255 SQLDCPNAM_m; DRDA TYPE NVCM; ENVLID 0x3F; Length Override 255 SQLDCPNAM_s; DRDA TYPE NVCS; ENVLID 0x33; Length Override 255 SQLDCXGRP; DRDA TYPE N-GDA; ENVLID 0xD3; Length Override 1

Throws:
DRDAProtocolException

writeSQLDIAGCN

private void writeSQLDIAGCN()
                     throws DRDAProtocolException
Throws:
DRDAProtocolException

writeSQLDARD

private void writeSQLDARD(DRDAStatement stmt,
                          boolean rtnOutput,
                          java.sql.SQLException e)
                   throws DRDAProtocolException,
                          java.sql.SQLException
Write SQLDARD SQLDARD : FDOCA EARLY ARRAY SQL Descriptor Area Row Description with SQL Communications Area FORMAT FOR SQLAM <= 6 SQLCARD; ROW LID 0x64; ELEMENT TAKEN 0(all); REP FACTOR 1 SQLNUMROW; ROW LID 0x68; ELEMENT TAKEN 0(all); REP FACTOR 1 SQLDAROW; ROW LID 0x60; ELEMENT TAKEN 0(all); REP FACTOR 0(all) FORMAT FOR SQLAM >= 7 SQLCARD; ROW LID 0x64; ELEMENT TAKEN 0(all); REP FACTOR 1 SQLDHROW; ROW LID 0xE0; ELEMENT TAKEN 0(all); REP FACTOR 1 SQLNUMROW; ROW LID 0x68; ELEMENT TAKEN 0(all); REP FACTOR 1

Parameters:
stmt - prepared statement
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

writeQRYDSC

private void writeQRYDSC(DRDAStatement stmt,
                         boolean FDODSConly)
                  throws DRDAProtocolException,
                         java.sql.SQLException
Write QRYDSC - Query Answer Set Description

Parameters:
stmt - DRDAStatement we are working on
FDODSConly - simply the FDODSC, without the wrap Instance Variables SQLDTAGRP - required Only 84 columns can be sent in a single QRYDSC. If there are more columns they must be sent in subsequent QRYDSC. If the QRYDSC will not fit into the current block, as many columns as can fit are sent and then the remaining are sent in the following blocks.
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

writeSQLDTAGRP

private void writeSQLDTAGRP(DRDAStatement stmt,
                            java.sql.ResultSetMetaData rsmeta,
                            EmbedParameterSetMetaData pmeta,
                            int colStart,
                            int colEnd,
                            boolean first)
                     throws DRDAProtocolException,
                            java.sql.SQLException
Write SQLDTAGRP SQLDAGRP : Late FDOCA GROUP SQL Data Value Group Descriptor LENGTH - length of the SQLDTAGRP TRIPLET_TYPE - NGDA for first, CPT for following ID - SQLDTAGRP_LID for first, NULL_LID for following For each column DRDA TYPE LENGTH OVERRIDE For numeric/decimal types PRECISON SCALE otherwise LENGTH or DISPLAY_WIDTH

Parameters:
stmt - drda statement
rsmeta - resultset meta data
pmeta - parameter meta data for CallableStatement
colStart - starting column for group to send
colEnd - end column to send
first - is this the first group
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

writeSQLDHROW

private void writeSQLDHROW(DRDAStatement stmt)
                    throws DRDAProtocolException,
                           java.sql.SQLException
Throws:
DRDAProtocolException
java.sql.SQLException

writeQRYDTA

private void writeQRYDTA(DRDAStatement stmt)
                  throws DRDAProtocolException,
                         java.sql.SQLException
Write QRYDTA - Query Answer Set Data Contains some or all of the answer set data resulting from a query returns true if there is more data, false if we reached the end Instance Variables Byte string

Parameters:
stmt - DRDA statement we are processing
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

writeFDODTA

private boolean writeFDODTA(DRDAStatement stmt)
                     throws DRDAProtocolException,
                            java.sql.SQLException
Throws:
DRDAProtocolException
java.sql.SQLException

splitQRYDTA

private void splitQRYDTA(DRDAStatement stmt,
                         int blksize)
                  throws java.sql.SQLException,
                         DRDAProtocolException
Split QRYDTA into blksize chunks

Parameters:
stmt - DRDA statment
blksize - size of query block
Throws:
SQLException, - DRDAProtocolException
java.sql.SQLException
DRDAProtocolException

doneData

private void doneData(DRDAStatement stmt,
                      java.sql.ResultSet rs)
               throws DRDAProtocolException,
                      java.sql.SQLException
Done data Send SQLCARD for the end of the data

Parameters:
stmt - DRDA statement
rs - Result set
Throws:
DRDAProtocolException,SQLException
DRDAProtocolException
java.sql.SQLException

positionCursor

private boolean positionCursor(DRDAStatement stmt,
                               java.sql.ResultSet rs)
                        throws java.sql.SQLException,
                               DRDAProtocolException
Position cursor for insensitive scrollable cursors

Parameters:
stmt - DRDA statement
rs - Result set
Throws:
java.sql.SQLException
DRDAProtocolException

writeSQLDAGRP

private void writeSQLDAGRP(java.sql.ResultSetMetaData rsmeta,
                           EmbedParameterSetMetaData pmeta,
                           int elemNum,
                           boolean rtnOutput)
                    throws DRDAProtocolException,
                           java.sql.SQLException
Write SQLDAGRP SQLDAGRP : EARLY FDOCA GROUP SQL Data Area Group Description FORMAT FOR SQLAM <= 6 SQLPRECISION; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLSCALE; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLLENGTH; DRDA TYPE I4; ENVLID 0x02; Length Override 4 SQLTYPE; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLCCSID; DRDA TYPE FB; ENVLID 0x26; Length Override 2 SQLNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 30 SQLNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 30 SQLLABEL_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 30 SQLLABEL_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 30 SQLCOMMENTS_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 254 SQLCOMMENTS_m; DRDA TYPE VCS; ENVLID 0x32; Length Override 254 FORMAT FOR SQLAM == 6 SQLPRECISION; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLSCALE; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLLENGTH; DRDA TYPE I8; ENVLID 0x16; Length Override 8 SQLTYPE; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLCCSID; DRDA TYPE FB; ENVLID 0x26; Length Override 2 SQLNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 30 SQLNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 30 SQLLABEL_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 30 SQLLABEL_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 30 SQLCOMMENTS_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 254 SQLCOMMENTS_m; DRDA TYPE VCS; ENVLID 0x32; Length Override 254 SQLUDTGRP; DRDA TYPE N-GDA; ENVLID 0x51; Length Override 0 FORMAT FOR SQLAM >= 7 SQLPRECISION; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLSCALE; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLLENGTH; DRDA TYPE I8; ENVLID 0x16; Length Override 8 SQLTYPE; DRDA TYPE I2; ENVLID 0x04; Length Override 2 SQLCCSID; DRDA TYPE FB; ENVLID 0x26; Length Override 2 SQLDOPTGRP; DRDA TYPE N-GDA; ENVLID 0xD2; Length Override 0

Parameters:
rsmeta - resultset meta data
pmeta - parameter meta data
elemNum - column number we are returning (in case of result set), or, parameter number (in case of parameter)
rtnOutput - whether this is for a result set
Throws:
DRDAProtocolException, - SQLException
DRDAProtocolException
java.sql.SQLException

writeVCMorVCS

private void writeVCMorVCS(java.lang.String s)
                    throws DRDAProtocolException
Write variable character mixed byte or single byte The preference is to write mixed byte if it is defined for the server, since that is our default and we don't allow it to be changed, we always write mixed byte.

Parameters:
s - string to write
Throws:
DRDAProtocolException

writeSQLUDTGRP

private void writeSQLUDTGRP(java.sql.ResultSetMetaData rsmeta,
                            EmbedParameterSetMetaData pmeta,
                            int jdbcElemNum,
                            boolean rtnOutput)
                     throws DRDAProtocolException,
                            java.sql.SQLException
Throws:
DRDAProtocolException
java.sql.SQLException

writeSQLDOPTGRP

private void writeSQLDOPTGRP(java.sql.ResultSetMetaData rsmeta,
                             EmbedParameterSetMetaData pmeta,
                             int jdbcElemNum,
                             boolean rtnOutput)
                      throws DRDAProtocolException,
                             java.sql.SQLException
Throws:
DRDAProtocolException
java.sql.SQLException

writeSQLDXGRP

private void writeSQLDXGRP(java.sql.ResultSetMetaData rsmeta,
                           EmbedParameterSetMetaData pmeta,
                           int jdbcElemNum,
                           boolean rtnOutput)
                    throws DRDAProtocolException,
                           java.sql.SQLException
Throws:
DRDAProtocolException
java.sql.SQLException

writeFdocaVal

protected void writeFdocaVal(int index,
                             java.lang.Object val,
                             int drdaType,
                             int precision,
                             int scale,
                             boolean valNull,
                             DRDAStatement stmt)
                      throws DRDAProtocolException,
                             java.sql.SQLException
Write Fdoca Value to client

Parameters:
index - Index of column being returned
val - Value to write to client
drdaType - FD:OCA DRDA Type from FdocaConstants
precision - Precision
stmt - Statement being processed
Throws:
DRDAProtocolException
java.sql.SQLException
See Also:
FdocaConstants

writeNullability

private void writeNullability(int drdaType,
                              boolean valNull)
write nullability if this is a nullable drdatype and FDOCA null value if appropriate

Parameters:
drdaType - FDOCA type
valNull - true if this is a null value. False otherwise

copyToRequired

private void copyToRequired(int[] req)
Copy a list of required code points to template for checking

Parameters:
req - list of required codepoints

removeFromRequired

private void removeFromRequired(int codePoint)
Remove codepoint from required list

Parameters:
codePoint - - code point to be removed

checkRequired

private void checkRequired(int codePoint)
                    throws DRDAProtocolException
Check whether we have seen all the required code points

Parameters:
codePoint - code point for which list of code points is required
Throws:
DRDAProtocolException

tooMany

private void tooMany(int codePoint)
              throws DRDAProtocolException
Seen too many of this code point

Parameters:
codePoint - code point which has been duplicated
Throws:
DRDAProtocolException

tooBig

private void tooBig(int codePoint)
             throws DRDAProtocolException
Object too big

Parameters:
codePoint - code point with too big object
Throws:
DRDAProtocolException

badObjectLength

private void badObjectLength(int codePoint)
                      throws DRDAProtocolException
Object length not allowed

Parameters:
codePoint - code point with bad object length
Throws:
DRDAProtocolException

rdbNotFound

private void rdbNotFound(java.lang.String rdbnam)
                  throws DRDAProtocolException
RDB not found

Parameters:
rdbnam - name of database
Throws:
DRDAProtocolException

invalidValue

private void invalidValue(int codePoint)
                   throws DRDAProtocolException
Invalid value for this code point

Parameters:
codePoint - code point value
Throws:
DRDAProtocolException

invalidCodePoint

protected void invalidCodePoint(int codePoint)
                         throws DRDAProtocolException
Invalid codepoint for this command

Parameters:
codePoint - code point value
Throws:
DRDAProtocolException

codePointNotSupported

protected void codePointNotSupported(int codePoint)
                              throws DRDAProtocolException
Don't support this code point

Parameters:
codePoint - code point value
Throws:
DRDAProtocolException

valueNotSupported

private void valueNotSupported(int codePoint)
                        throws DRDAProtocolException
Don't support this value

Parameters:
codePoint - code point value
Throws:
DRDAProtocolException

verifyRequiredObject

private void verifyRequiredObject(int codePoint,
                                  int reqCodePoint)
                           throws DRDAProtocolException
Verify that the code point is the required code point

Parameters:
codePoint - code point we have
reqCodePoint - code point required at this time
Throws:
DRDAProtocolException

verifyInOrderACCSEC_SECCHK

private void verifyInOrderACCSEC_SECCHK(int codePoint,
                                        int reqCodePoint)
                                 throws DRDAProtocolException
Verify that the code point is in the right order

Parameters:
codePoint - code point we have
reqCodePoint - code point required at this time
Throws:
DRDAProtocolException

rdbnamMismatch

private void rdbnamMismatch(int codePoint)
                     throws DRDAProtocolException
Database name given under code point doesn't match previous database names

Parameters:
codePoint - codepoint where the mismatch occurred
Throws:
DRDAProtocolException

closeSession

private void closeSession()
Close the current session


handleException

private void handleException(java.lang.Exception e)
Handle Exceptions - write error protocol if appropriate and close session or thread as appropriate


sendUnexpectedException

private void sendUnexpectedException(java.lang.Exception e)
Send unpexpected error to the client

Parameters:
e - Exception to be sent

closed

private boolean closed()
Test if DRDA connection thread is closed

Returns:
true if close; false otherwise

getLogConnections

private boolean getLogConnections()
Get whether connections are logged

Returns:
true if connections are being logged; false otherwise

getTimeSlice

private long getTimeSlice()
Get time slice value for length of time to work on a session

Returns:
time slice

trace

protected void trace(java.lang.String value)
Send string to console

Parameters:
value - - value to print on console

showmem

public static void showmem()
Show runtime memory


convertToHexString

private java.lang.String convertToHexString(byte[] buf)
convert byte array to a Hex string

Parameters:
buf - buffer to convert
Returns:
hex string representation of byte array

checkValidTypDefNam

private void checkValidTypDefNam(java.lang.String typdefnam)
                          throws DRDAProtocolException
check that the given typdefnam is acceptable

Parameters:
typdefnam -
Throws:
DRDAProtocolException

checkLength

private void checkLength(int codepoint,
                         int reqlen)
                  throws DRDAProtocolException
Check that the length is equal to the required length for this codepoint

Parameters:
codepoint - codepoint we are checking
reqlen - required length
Throws:
DRDAProtocolException

readBoolean

private boolean readBoolean(int codepoint)
                     throws DRDAProtocolException
Read and check a boolean value

Parameters:
codepoint - codePoint to be used in error reporting
Returns:
true or false depending on boolean value read
Throws:
DRDAProtocolException

addDatabase

private void addDatabase(java.lang.String dbname)
Add a database to the current session


setDatabase

private void setDatabase(int codePoint)
                  throws DRDAProtocolException
Set the current database

Parameters:
codePoint - codepoint we are processing
Throws:
DRDAProtocolException

writeENDUOWRM

private void writeENDUOWRM(int opType)
Write ENDUOWRM Instance Variables SVCOD - severity code - WARNING - required UOWDSP - Unit of Work Disposition - required RDBNAM - Relational Database name - optional SRVDGN - Server Diagnostics information - optional

Parameters:
opType - - operation type 1 - commit, 2 -rollback

writeEXTDTA

void writeEXTDTA(DRDAStatement stmt)
           throws java.sql.SQLException,
                  DRDAProtocolException
Throws:
java.sql.SQLException
DRDAProtocolException

checkWarning

private void checkWarning(java.sql.Connection conn,
                          java.sql.Statement stmt,
                          java.sql.ResultSet rs,
                          int updateCount,
                          boolean alwaysSend,
                          boolean sendWarn)
                   throws DRDAProtocolException,
                          java.sql.SQLException
Check SQLWarning and write SQLCARD as needed.

Parameters:
conn - connection to check
stmt - statement to check
rs - result set to check
updateCount - update count to include in SQLCARD
alwaysSend - whether always send SQLCARD regardless of the existance of warnings
sendWarn - whether to send any warnings or not.
Throws:
DRDAProtocolException
java.sql.SQLException

buildRuntimeInfo

protected java.lang.String buildRuntimeInfo(java.lang.String indent,
                                            LocalizedResource localLangUtil)

finalizeChain

private void finalizeChain()
                    throws DRDAProtocolException
Finalize the current DSS chain and send it if needed.

Throws:
DRDAProtocolException

Built on Tue 2006-10-10 19:23:47+0200, from revision exported

Apache Derby V10.1 Engine Documentation - Copyright © 1997,2005 The Apache Software Foundation or its licensors, as applicable.