Class DRDAConnThread
- All Implemented Interfaces:
Runnable
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static int[]
private AppRequester
private static final String
private static final String
private boolean
End this thread.private static final int
private int
private int
private Database
private SQLException
private static DecryptionManager
private boolean
Tells if the reset / connect request is a deferred request.private byte
private static final DRDAProtocolExceptionInfo
private static final byte[]
private static final byte[]
private static final byte[]
private Calendar
A cachedCalendar
instance using the GMT time zone.private static final String
private boolean
Whether or not to log connections.private static HeaderPrintWriter
private static int
private static final int
private static final int
private static final int
private static final int
private static final int
private byte[]
private byte[]
private static final byte
private static final byte[]
private int
private DRDAString
Current RDB Package Consistency Token.private DRDAString
Current RDB Package Identifier.private int
Current RDB Package Section Number.private static byte[]
private Pkgnamcsn
The value returned by the previous call toparsePKGNAMCSN()
.private DRDAString
Current RDB Collection Identifier.private DRDAString
Current RDB Package Name.private DDMReader
private int[]
private static final String
private static final int
private boolean
private NetworkServerControlImpl
private Session
private InputStream
private OutputStream
private int
private static String
SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER
, When full message text is sent for severe errors.private static String
SQLERRMC_TOKEN_DELIMITER
separates message argument tokensprivate static final String
private static final String
private long
Time slice for this thread.private static final byte[]
private DDMWriter
private DRDAXAProtocol
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionDRDAConnThread
(Session session, NetworkServerControlImpl server, long timeSlice, boolean logConnections) Create a new Thread for processing session requests -
Method Summary
Modifier and TypeMethodDescriptionprotected void
agentError
(String msg) Agent error - something very bad happenedprivate void
badObjectLength
(int codePoint) Object length not allowedprivate String
Build the SQLERRMC for ajava.sql.DataTruncation
warning.private String
Build preformatted SQLException text for severe exceptions or SQLExceptions that are not Derby exceptions.protected String
buildRuntimeInfo
(String indent, LocalizedResource localLangUtil) private String
Create error message or message argements to return to client.private String
Build Tokenized SQLERRMC to just send the tokenized arguments to the client.private boolean
canIgnoreStmt
(String stmt) private void
checkLength
(int codepoint, int reqlen) Check that the length is equal to the required length for this codepointprivate void
checkRequired
(int codePoint) Check whether we have seen all the required code pointsprivate void
checkValidTypDefNam
(String typdefnam) check that the given typdefnam is acceptableprivate void
checkWarning
(Connection conn, Statement stmt, ResultSet rs, long updateCount, boolean alwaysSend, boolean sendWarn) Check SQLWarning and write SQLCARD as needed.private void
cleanUpAndCloseResultSet
(DRDAStatement stmt, SQLException sqle, int writerMark) Cleans up and closes a result set if an exception is thrown when collecting QRYDTA in response to OPNQRY or CNTQRY.protected void
close()
Close DRDA connection threadprivate boolean
closed()
Test if DRDA connection thread is closedprivate void
Close the current sessionprivate static void
closeStream
(InputStream stream) Close a stream.protected void
codePointNotSupported
(int codePoint) Don't support this code pointprivate static InputStream
private String
convertToHexString
(byte[] buf) convert byte array to a Hex stringprivate void
copyToRequired
(int[] req) Copy a list of required code points to template for checkingprivate void
doneData
(DRDAStatement stmt, ResultSet rs) Done data Send SQLCARD for the end of the dataprivate void
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
Exchange server attributes with application requesterprivate void
Finalize the current DSS chain and send it if needed.private static Object
findService
(String factoryInterface, String serviceName) Privileged service lookup.private String
formatDate
(Date date) Convert ajava.sql.Date
to a string with the format expected by the client.private String
formatTime
(Time time) Convert ajava.sql.Time
to a string with the format expected by the client.private String
Convert ajava.sql.Timestamp
to a string with the format expected by the client.private int
(package private) long
(package private) long
private int
Get connection from a database name Username and password is verified by making a connection to the databaseprotected int
Get correlation idprotected byte[]
Get correlation tokenprotected Database
Get Database we are working onprotected String
Get database nameprivate int
Translate from Derby exception severity to SVRCODprivate Calendar
Get aCalendar
instance with time zone set to GMT.protected InputStream
Get input streamprivate boolean
Get whether connections are loggedprivate static ModuleFactory
Privileged Monitor lookup.private Object
getObjectForWriteFdoca
(CallableStatement cs, int index, int drdaType) Get the value of an output parameter of the specified type from aCallableStatement
, in a form suitable for being writted bywriteFdocaVal(int, java.lang.Object, int, int, int, boolean, org.apache.derby.impl.drda.DRDAStatement, boolean)
.private Object
getObjectForWriteFdoca
(ResultSet rs, int index, int drdaType) Get a column value of the specified type from aResultSet
, in a form suitable for being writted bywriteFdocaVal(int, java.lang.Object, int, int, int, boolean, org.apache.derby.impl.drda.DRDAStatement, boolean)
.protected OutputStream
Get output streamprivate static byte[]
Get product id as bytesprivate int
protected DDMReader
get DDMReaderprotected NetworkServerControlImpl
Get serverprotected Session
Get session we are working onprivate int
Get the SQLCODE to send for an exception or a warning.private long
Get time slice value for length of time to work on a sessionprotected DDMWriter
get DDMWriterprivate void
Handle Exceptions - write error protocol if appropriate and close session or thread as appropriate(package private) boolean
private void
Initialize classprivate void
initializeDatabase
(String dbname) Create a new database and intialize the DRDAConnThread database.private void
Initialize for a new sessionprivate void
invalidClient
(String prdid) Invalid non-derby client tried to connect.protected void
invalidCodePoint
(int codePoint) Invalid codepoint for this commandprivate void
invalidValue
(int codePoint) Invalid value for this code pointprivate boolean
isAuthenticationException
(SQLException sqlException) There are multiple reasons for not getting a connection, and all these should throw SQLExceptions with SQL state 08004 according to the SQL standard.protected void
Indicate a communications failure.protected void
markCommunicationsFailure
(String arg1, String arg2, String arg3, String arg4) Indicate a communications failureprotected void
missingCodePoint
(int codePoint) Missing code pointprivate void
padInt
(char[] buf, int offset, int length, int value) Insert an integer into a char array and pad it with leading zeros if its string representation is shorter thanlength
characters.private int
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 - optionalprivate int
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 String
parseCcsidMBC
(int length) Parse mixed character stringprivate String
parseCcsidSBC
(int length) Parse single byte character stringprivate DRDAStatement
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
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
Parse CNTQRY objects Instance Variables OUTOVR - Output Override Descriptor - optionalprivate Date
Parse a date string as it is received from the client.private boolean
private boolean
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 String
Parse an encoded data string from the Application Requesterprivate void
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, ignorableprivate void
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, ignorableprivate long
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 -requiredprivate boolean
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
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
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 Derby 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 boolean
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 String
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 managersprivate void
Parse MONITOR DRDA spec says this is optional.private String
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 stringprivate Pkgnamcsn
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
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
Parse OUTOVROPT - this indicates whether output description can be overridden on just the first CNTQRY or on any CNTQRYprivate Pkgnamcsn
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 Numberprivate String
private int
Parse PRPSQLSTT - Prepare SQL Statement Instance Variables RDBNAM - Relational Database Name - optional PKGNAMCSN - RDB Package Name, Consistency Token, and Section Number - required RTNSQLDA - Return SQL Descriptor Area - optional MONITOR - Monitor events - optional.private String
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
Parse QRYBLSZ - this gives the maximum size of the query blocks that can be returned to the requesterprivate int
Parse a QRYCLSIMP - Implicitly close non-scrollable cursor after end of data.private int
private int
parseQRYROWSET
(int minVal) Parse QRYROWSET - this is the number of rows to returnprivate void
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 nowprivate String
Parse database nameprivate int
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
(DRDAStatement stmt) Parse SQLDTA - SQL program variable data and handle exception.private void
Parse SQLDTA - SQL program variable data Instance Variables FDODSC - FD:OCA data descriptor - required FDODTA - FD:OCA data - optionalprivate String
Parse SQLSTT Dssprivate Time
Parse a time string as it is received from the client.private Timestamp
parseTimestamp
(String timeString, Calendar cal) Parse a timestamp string as it is received from the client.private String
Parse TYPDEFNAMprivate void
Parse Type Defintion Overrides TYPDEF Overrides specifies the Coded Character SET Identifiers (CCSIDs) that are in a named TYPDEF.private boolean
Parse TYPSQLDA - Type of the SQL Descriptor Areaprivate String
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-zeroprivate boolean
positionCursor
(DRDAStatement stmt, ResultSet rs) Position cursor for insensitive scrollable cursorsprotected static void
println2Log
(String dbname, String drdaID, String msg) Print a line to the DB2j logprivate void
Process DRDA commands we can receive once server attributes have been exchanged.private boolean
Process remainder data resulting from a split.private void
rdbnamMismatch
(int codePoint) Database name given under code point doesn't match previous database namesprivate void
rdbNotFound
(String rdbnam) RDB not foundprivate void
readAndSetAllExtParams
(DRDAStatement stmt, boolean streamLOB) private void
readAndSetExtParam
(int i, DRDAStatement stmt, int drdaType, int extLen, boolean streamLOB) Read different types of input parameters and set them in PreparedStatementprivate void
readAndSetParams
(int i, DRDAStatement stmt, ParameterMetaData pmeta) Read different types of input parameters and set them in PreparedStatementprivate boolean
readBoolean
(int codepoint) Read and check a boolean valueprivate long
readLobLength
(int extLenIndicator) private Object
readUDT()
Read a UDT from the streamprivate void
removeFromRequired
(int codePoint) Remove codepoint from required listprivate void
requiredValueNotFound
(int codePoint) Required value not found.void
run()
Main routine for thread, loops until the thread is closed Gets a session, does work for the sessionprivate void
Notice the client about a protocol error.private void
Send unpexpected error to the clientprivate void
In initial state for a session, determine whether this is a command session or a DRDA protocol session.private static void
setAsBinaryStream
(DRDAStatement stmt, int index, EXTDTAReaderInputStream stream, boolean streamLOB) Sets the specified binary EXTDTA parameter of the embedded statement.private static void
setAsCharacterStream
(DRDAStatement stmt, int i, EXTDTAReaderInputStream extdtaStream, boolean streamLOB, String encoding) Sets the specified character EXTDTA parameter of the embedded statement.private void
setDatabase
(int codePoint) Set the current databaseprotected void
setLogConnections
(boolean value) Set logging of connectionsprivate void
setStmtOrDbByteOrder
(boolean setDatabase, DRDAStatement stmt, String typDefNam) Set a statement or the database' byte order, depending on the argumentsprotected void
setTimeSlice
(long value) Set time slice valuestatic void
showmem()
Show runtime memoryprivate void
skipRemainder
(boolean onlySkipSameIds) Skip remainder of current DSS and all chained DSS'esprivate void
splitQRYDTA
(DRDAStatement stmt, int blksize) Split QRYDTA into blksize chunks This routine is called if the QRYDTA data will not fit.private int
svrcodFromSecchkcd
(int securityCheckCode) Calculate SVRCOD value from SECCHKCDprivate void
Switch the DDMWriter and DDMReader to EBCDICprivate void
Switch the DDMWriter and DDMReader to UTF8 IF supportedprotected void
throwSyntaxrm
(int errcd, int cpArg) Syntax errorprivate void
tooBig
(int codePoint) Object too bigprivate void
tooMany
(int codePoint) Seen too many of this code pointprotected void
Send string to consoleprivate void
traceEXTDTARead
(int drdaType, int index, EXTDTAReaderInputStream stream, boolean streamLOB, String encoding) Sends a trace string to the console when reading an EXTDTA value (if tracing is enabled).private int
Validate SECMEC_USRSSBPWD (Strong Password Substitute) can be used as DRDA security mechanism.private void
valueNotSupported
(int codePoint) Don't support this valueprivate void
verifyInOrderACCSEC_SECCHK
(int codePoint, int reqCodePoint) Verify that the code point is in the right orderprivate void
verifyRequiredObject
(int codePoint, int reqCodePoint) Verify that the code point is the required code pointprivate int
Verify userId and password Username and password is verified by making a connection to the databaseprivate void
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 Listprivate 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 - requiredprivate 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 - optionalprivate void
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, Object val, int drdaType, int precision, int scale, boolean valNull, DRDAStatement stmt, boolean isParam) Write Fdoca Value to clientprivate boolean
writeFDODTA
(DRDAStatement stmt) This routine places some data into the current QRYDTA block using FDODTA (Formatted Data Object DaTA rules).private void
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 appropriateprivate void
Write a null SQLCARD as an objectprivate void
Write a OPNQFLRM - Open Query Failure Instance Variables SVRCOD - Severity Code - required - 8 ERROR RDBNAM - Relational Database Name - requiredprivate 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 - optionalprivate void
Piggy-back any modified session attributes on the current message.private void
private void
writePKGNAMCSN
(byte[] pkgcnstkn) 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 stringsprivate void
writeQRYDSC
(DRDAStatement stmt, boolean FDODSConly) Write QRYDSC - Query Answer Set Descriptionprivate void
writeQRYDTA
(DRDAStatement stmt) Write QRYDTA - Query Answer Set Data Contains some or all of the answer set data resulting from a query If the client is not using rowset processing, this routine attempts to pack as much data into the QRYDTA as it can.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 - requiredprivate void
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 - requiredprivate 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
(String rdbnam) Write RDBNAMprivate void
Write RDBUPDRM Instance variables SVRCOD - Severity code - Information only - required RDBNAM - Relational database name -required SRVDGN - Server Diagnostic Information -optionalprivate void
writeRSLSETRM
(DRDAStatement stmt) Write RSLSETRM Instance variables SVRCOD - Severity code - Information only - required PKGSNLST - list of PKGNAMCSN -required SRVDGN - Server Diagnostic Information -optionalprivate 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 Informationprivate void
writeSQLCAERRWARN
(long updateCount, long rowCount) Write the ERR and WARN part of the SQLCAprivate void
writeSQLCAGRP
(byte[] sqlState, int sqlcode, long updateCount, long rowCount) Same as writeSQLCAGRP, but optimized for the case when there is no real exception, i.e. the exception is null, or "End of data" 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 0private void
writeSQLCAGRP
(SQLException e, long 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 0private void
writeSQLCARD
(SQLException e, long updateCount, long rowCount) private void
writeSQLCARDs
(SQLException e, long updateCount) private void
writeSQLCARDs
(SQLException e, long updateCount, boolean sendSQLERRRM) private void
writeSQLCAXGRP
(long updateCount, long rowCount, String sqlerrmc, 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 1024 SQLERRMSG_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 70 SQLERRMSG_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 70private void
writeSQLCINRD
(DRDAStatement stmt) Write SQLCINRD - result set column informationprivate void
writeSQLDAGRP
(ResultSetMetaData rsmeta, ParameterMetaData 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 0private void
writeSQLDARD
(DRDAStatement stmt, boolean rtnOutput, 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 1private void
writeSQLDCGRP
(long rowNum, int sqlCode, String sqlState, String dbname, 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 1private void
writeSQLDCROW
(long rowNum, int sqlCode, String sqlState, String dbname, String sqlerrmc) writeSQLDCROW: SQL Diagnostics Condition Row - Identity 0xE5 SQLDCGRP; GROUP LID 0xD5; ELEMENT TAKEN 0(all); REP FACTOR 1private void
writeSQLDHROW
(int holdability) Holdability passed in as it can represent the holdability of the statement or a specific result set.private void
writeSQLDIAGCI
(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
private void
writeSQLDIAGGRP
(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 0private void
private void
writeSQLDOPTGRP
(ResultSetMetaData rsmeta, ParameterMetaData pmeta, int jdbcElemNum, boolean rtnOutput) private void
writeSQLDTAGRP
(DRDAStatement stmt, ResultSetMetaData rsmeta, ParameterMetaData 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_WIDTHprivate void
writeSQLDXGRP
(ResultSetMetaData rsmeta, ParameterMetaData pmeta, int jdbcElemNum, boolean rtnOutput) private void
writeSQLERRRM
(int severity) Write SQLERRRM Instance Variables SVRCOD - Severity Code - requiredprivate void
writeSQLNUMGRP
(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 2private void
writeSQLNUMROW
(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 1private void
writeSQLRSLRD
(DRDAStatement stmt) Write SQLRSLRD - result set reply dataprivate void
writeSQLUDTGRP
(ResultSetMetaData rsmeta, ParameterMetaData pmeta, int jdbcElemNum, boolean rtnOutput) Write SQLUDTGRP (SQL Descriptor User-Defined Type Group Descriptor) This is the format from the DRDA spec, Volume 1, section 5.6.4.10.private void
private void
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, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
leftBrace
- See Also:
-
rightBrace
- See Also:
-
NULL_VALUE
private static final byte NULL_VALUE- See Also:
-
SYNTAX_ERR
- See Also:
-
MGRLVL_3
private static final int MGRLVL_3- See Also:
-
MGRLVL_4
private static final int MGRLVL_4- See Also:
-
MGRLVL_5
private static final int MGRLVL_5- See Also:
-
MGRLVL_6
private static final int MGRLVL_6- See Also:
-
MGRLVL_7
private static final int MGRLVL_7- See Also:
-
COMMIT
private static final int COMMIT- See Also:
-
ROLLBACK
private static final int ROLLBACK- See Also:
-
correlationID
private int correlationID -
sockis
-
sockos
-
reader
-
writer
-
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
-
session
-
timeSlice
private volatile long timeSliceTime slice for this thread. -
logConnections
private volatile boolean logConnectionsWhether or not to log connections. -
sendWarningsOnCNTQRY
private boolean sendWarningsOnCNTQRY -
close
private volatile boolean closeEnd this thread. -
logStream
-
appRequester
-
database
-
sqlamLevel
private int sqlamLevel -
diagnosticLevel
private byte diagnosticLevel -
unknownManagers
-
knownManagers
-
databaseAccessException
-
prevPkgnamcsn
The value returned by the previous call toparsePKGNAMCSN()
. -
rdbnam
Current RDB Package Name. -
rdbcolid
Current RDB Collection Identifier. -
pkgid
Current RDB Package Identifier. -
pkgcnstkn
Current RDB Package Consistency Token. -
pkgsn
private int pkgsnCurrent RDB Package Section Number. -
TIMEOUT_STATEMENT
- See Also:
-
pendingStatementTimeout
private int pendingStatementTimeout -
decryptionManager
-
myPublicKey
private byte[] myPublicKey -
myTargetSeed
private byte[] myTargetSeed -
prdIdBytes
private static byte[] prdIdBytes -
eod00000
private static final byte[] eod00000 -
eod02000
private static final byte[] eod02000 -
nullSQLState
private static final byte[] nullSQLState -
errD5_D6
private static final byte[] errD5_D6 -
warn0_warnA
private static final byte[] warn0_warnA -
AUTHENTICATION_PROVIDER_BUILTIN_CLASS
- See Also:
-
AUTHENTICATION_PROVIDER_NONE_CLASS
- See Also:
-
dummy
-
deferredReset
private boolean deferredResetTells if the reset / connect request is a deferred request. This information is used to work around a bug (DERBY-3596) in a compatible manner, which also avoids any changes in the client driver.The bug manifests itself when a connection pool data source is used and logical connections are obtained from the physical connection associated with the data source. Each new logical connection causes a new physical connection on the server, including a new transaction. These connections and transactions are not closed / cleaned up.
-
gmtCalendar
A cachedCalendar
instance using the GMT time zone. -
SQLERRMC_TOKEN_DELIMITER
SQLERRMC_TOKEN_DELIMITER
separates message argument tokens -
SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER
SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER
, When full message text is sent for severe errors. This value separates the messages.
-
-
Constructor Details
-
DRDAConnThread
DRDAConnThread(Session session, NetworkServerControlImpl server, long timeSlice, boolean logConnections) Create a new Thread for processing session requests- Parameters:
session
- Session requesting processingserver
- Server starting threadtimeSlice
- timeSlice for threadlogConnections
-
-
-
Method Details
-
run
public void run()Main routine for thread, loops until the thread is closed Gets a session, does work for the session -
getInputStream
Get input stream- Returns:
- input stream
-
getOutputStream
Get output stream- Returns:
- output stream
-
getProductIDBytes
private static byte[] getProductIDBytes()Get product id as bytes -
getReader
get DDMReader- Returns:
- DDMReader for this thread
-
getWriter
get DDMWriter- Returns:
- DDMWriter for this thread
-
getCorrelationID
protected int getCorrelationID()Get correlation id- Returns:
- correlation id
-
getSession
Get session we are working on- Returns:
- session
-
getDatabase
Get Database we are working on- Returns:
- database
-
getServer
Get server- Returns:
- server
-
getCrrtkn
protected byte[] getCrrtkn()Get correlation token- Returns:
- crrtkn
-
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(String arg1, String arg2, String arg3, String arg4) throws DRDAProtocolException Indicate a communications failure- Parameters:
arg1
- - info about the communications failurearg2
- - info about the communications failurearg3
- - info about the communications failurearg4
- - info about the communications failure- Throws:
DRDAProtocolException
- disconnect exception always thrown
-
markCommunicationsFailure
protected void markCommunicationsFailure(Exception e, String arg1, String arg2, String arg3, String arg4) throws DRDAProtocolException Indicate a communications failure. Log to derby.log- Parameters:
e
- - Source exception that was thrownarg1
- - info about the communications failurearg2
- - info about the communications failurearg3
- - info about the communications failurearg4
- - info about the communications failure- Throws:
DRDAProtocolException
- disconnect exception always thrown
-
throwSyntaxrm
Syntax error- Parameters:
errcd
- Error codecpArg
- code point value- Throws:
DRDAProtocolException
-
agentError
Agent error - something very bad happened- Parameters:
msg
- Message describing error- Throws:
DRDAProtocolException
- newAgentError always thrown
-
missingCodePoint
Missing code point- Parameters:
codePoint
- code point value- Throws:
DRDAProtocolException
-
println2Log
Print a line to the DB2j log- Parameters:
dbname
- database namedrdaID
- DRDA identifiermsg
- message
-
writeRDBNAM
Write RDBNAM- Parameters:
rdbnam
- database name- Throws:
DRDAProtocolException
-
initialize
private void initialize()Initialize class -
initializeForSession
private void initializeForSession()Initialize for a new session -
sessionInitialState
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:
Exception
-
cleanUpAndCloseResultSet
private void cleanUpAndCloseResultSet(DRDAStatement stmt, SQLException sqle, int writerMark) throws DRDAProtocolException Cleans up and closes a result set if an exception is thrown when collecting QRYDTA in response to OPNQRY or CNTQRY.- Parameters:
stmt
- the DRDA statement to clean upsqle
- the exception that was thrownwriterMark
- start index for the first DSS to clear from the output buffer- Throws:
DRDAProtocolException
- if a DRDA protocol error is detected
-
processCommands
Process DRDA commands we can receive once server attributes have been exchanged.- Throws:
DRDAProtocolException
-
errorInChain
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
Exchange server attributes with application requester- Throws:
DRDAProtocolException
-
parseDRDAConnection
- Throws:
DRDAProtocolException
-
switchToUtf8
private void switchToUtf8()Switch the DDMWriter and DDMReader to UTF8 IF supported -
switchToEbcdic
private void switchToEbcdic()Switch the DDMWriter and DDMReader to EBCDIC -
writeRDBfailure
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() -
isAuthenticationException
There are multiple reasons for not getting a connection, and all these should throw SQLExceptions with SQL state 08004 according to the SQL standard. Since only one of these SQL states indicate that an authentication error has occurred, it is not enough to check that the SQL state is 08004 and conclude that authentication caused the exception to be thrown. This method tries to get a StandardException from the SQLException and use getMessageId on that object to check for authentication error instead of the SQL state we get from SQLExceptions#getSQLState. getMessageId returns the entire id as defined in SQLState (e.g. 08004.C.1), while getSQLState only return the 5 first characters (i.e. 08004 instead of 08004.C.1) If the SQLException isn't linked to a StandardException, the assumption that SQL State 08004 is caused by an authentication failure is followed even though this is not correct. This was the pre DERBY-3060 way of solving the issue.- Parameters:
sqlException
- The exception that is checked to see if this is really caused by an authentication failure- Returns:
- true if sqlException is (or has to be assumed to be) caused by an authentication failure, false otherwise.
- See Also:
-
verifyUserIdPassword
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
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
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
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
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
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
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
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 - strong password substitute (USRSSBPWD w/ Derby network client only) 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
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:
- RDB Package Name, Consistency Token, and Section Number
- Throws:
DRDAProtocolException
SQLException
-
parseOPNQRYobjects
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
-
parseOUTOVROPT
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
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
Parse QRYROWSET - this is the number of rows to return- Parameters:
minVal
- - minimum value- Returns:
- query row set size
- Throws:
DRDAProtocolException
-
parseQRYCLSIMP
Parse a QRYCLSIMP - Implicitly close non-scrollable cursor after end of data.- Returns:
- true to close on end of data
- Throws:
DRDAProtocolException
-
parseQRYCLSRLS
- Throws:
DRDAProtocolException
-
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- Throws:
DRDAProtocolException
-
writeQRYNOPRM
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
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
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:
DRDAProtocolException
-
writePKGNAMCSN
- Throws:
DRDAProtocolException
-
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.- Returns:
- DRDAStatement we are continuing
- Throws:
DRDAProtocolException
SQLException
-
skipRemainder
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
Parse CNTQRY objects Instance Variables OUTOVR - Output Override Descriptor - optional- Parameters:
stmt
- DRDA statement we are working on- Throws:
DRDAProtocolException
SQLException
-
parseOUTOVR
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
SQLException
-
writePBSD
Piggy-back any modified session attributes on the current message. Writes a PBSD conataining one or both of PBSD_ISO and PBSD_SCHEMA. PBSD_ISO is followed by the jdbc isolation level as an unsigned byte. PBSD_SCHEMA is followed by the name of the current schema as an UTF-8 String.- Throws:
SQLException
DRDAProtocolException
-
writeOPNQRYRM
private void writeOPNQRYRM(boolean isDssObject, DRDAStatement stmt) throws DRDAProtocolException, 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
SQLException
-
writeENDQRYRM
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
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
Parse database name- Returns:
- database name
- Throws:
DRDAProtocolException
-
writeACCSECRD
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
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
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
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
Parse TYPDEFNAM- Returns:
- typdefnam
- Throws:
DRDAProtocolException
-
setStmtOrDbByteOrder
Set a statement or the database' byte order, depending on the arguments- Parameters:
setDatabase
- if true, set database' byte order, otherwise set statement'sstmt
- DRDAStatement, used when setDatabase is falsetypDefNam
- TYPDEFNAM value
-
writeACCRDBRM
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
- Throws:
DRDAProtocolException
-
parseTYPDEFOVR
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
Parse PRPSQLSTT - Prepare SQL Statement Instance Variables RDBNAM - Relational Database Name - optional PKGNAMCSN - 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
-
parsePRPSQLSTTobjects
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
-
parseTYPSQLDA
Parse TYPSQLDA - Type of the SQL Descriptor Area- Returns:
- true if for output; false otherwise
- Throws:
DRDAProtocolException
-
parseSQLATTR
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
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
-
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 Derby 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
-
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- Throws:
DRDAProtocolException
-
parseEXCSQLSTTobjects
private boolean parseEXCSQLSTTobjects(DRDAStatement stmt) throws DRDAProtocolException, 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
-
writeSQLCINRD
Write SQLCINRD - result set column information- Throws:
DRDAProtocolException
SQLException
-
writeSQLRSLRD
Write SQLRSLRD - result set reply data- Throws:
DRDAProtocolException
SQLException
-
writeRSLSETRM
Write RSLSETRM Instance variables SVRCOD - Severity code - Information only - required PKGSNLST - list of PKGNAMCSN -required SRVDGN - Server Diagnostic Information -optional- Throws:
DRDAProtocolException
SQLException
-
parseSQLDTA
Parse SQLDTA - SQL program variable data and handle exception.- Throws:
DRDAProtocolException
SQLException
- See Also:
-
parseSQLDTA_work
Parse SQLDTA - SQL program variable data Instance Variables FDODSC - FD:OCA data descriptor - required FDODTA - FD:OCA data - optional- Throws:
DRDAProtocolException
SQLException
-
getByteOrder
private int getByteOrder() -
getGMTCalendar
Get aCalendar
instance with time zone set to GMT. The instance is cached for reuse by this thread. This calendar can be used to consistently read and write date and time values using the same calendar. Since the local default calendar may not be able to represent all times (for instance because the time would fall into a non-existing hour of the day when switching to daylight saving time, see DERBY-4582), we use the GMT time zone which doesn't observe daylight saving time.- Returns:
- a calendar in the GMT time zone
-
readAndSetParams
private void readAndSetParams(int i, DRDAStatement stmt, ParameterMetaData pmeta) throws DRDAProtocolException, SQLException Read different types of input parameters and set them in PreparedStatement- Parameters:
i
- index of the parameterstmt
- drda statementpmeta
- parameter meta data- Throws:
DRDAProtocolException
SQLException
-
readUDT
Read a UDT from the stream- Throws:
DRDAProtocolException
-
readLobLength
- Throws:
DRDAProtocolException
-
parseDate
Parse a date string as it is received from the client.- Parameters:
dateString
- the date string to parsecal
- the calendar in which the date is parsed- Returns:
- a Date object representing the date in the specified calendar
- Throws:
IllegalArgumentException
- if the date is not correctly formatted- See Also:
-
parseTime
Parse a time string as it is received from the client.- Parameters:
timeString
- the time string to parsecal
- the calendar in which the time is parsed- Returns:
- a Date object representing the time in the specified calendar
- Throws:
IllegalArgumentException
- if the time is not correctly formatted- See Also:
-
parseTimestamp
Parse a timestamp string as it is received from the client.- Parameters:
timeString
- the time string to parsecal
- the calendar in which the timestamp is parsed- Returns:
- a Date object representing the timestamp in the specified calendar
- Throws:
IllegalArgumentException
- if the timestamp is not correctly formatted- See Also:
-
readAndSetAllExtParams
private void readAndSetAllExtParams(DRDAStatement stmt, boolean streamLOB) throws SQLException, DRDAProtocolException - Throws:
SQLException
DRDAProtocolException
-
readAndSetExtParam
private void readAndSetExtParam(int i, DRDAStatement stmt, int drdaType, int extLen, boolean streamLOB) throws DRDAProtocolException, SQLException Read different types of input parameters and set them in PreparedStatement- Parameters:
i
- zero-based index of the parameterstmt
- associated psdrdaType
- drda type of the parameter- Throws:
DRDAProtocolException
SQLException
-
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- Returns:
- update count
- Throws:
DRDAProtocolException
SQLException
-
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)- Throws:
DRDAProtocolException
SQLException
-
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. 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
-
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.- Throws:
DRDAProtocolException
SQLException
-
canIgnoreStmt
-
writeRDBUPDRM
Write RDBUPDRM Instance variables SVRCOD - Severity code - Information only - required RDBNAM - Relational database name -required SRVDGN - Server Diagnostic Information -optional- Throws:
DRDAProtocolException
-
parsePKGNAMCT
- Throws:
DRDAProtocolException
-
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- Returns:
Pkgnamcsn
value- Throws:
DRDAProtocolException
-
parseSQLSTTDss
Parse SQLSTT Dss- Throws:
DRDAProtocolException
-
parseEncodedString
Parse an encoded data string from the Application Requester- Returns:
- string value
- Throws:
DRDAProtocolException
-
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- Returns:
- string value
- Throws:
DRDAProtocolException
-
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- Returns:
- string value
- Throws:
DRDAProtocolException
-
parseCcsidMBC
Parse mixed character string- Returns:
- string value
- Throws:
DRDAProtocolException
-
parseCcsidSBC
Parse single byte character string- Returns:
- string value
- Throws:
DRDAProtocolException
-
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.- Returns:
- DRDAstatement being closed
- Throws:
DRDAProtocolException
SQLException
-
parseMONITOR
Parse MONITOR DRDA spec says this is optional. Since we don't currently support it, we just ignore.- Throws:
DRDAProtocolException
-
writeSQLCARDs
- Throws:
DRDAProtocolException
-
writeSQLCARDs
private void writeSQLCARDs(SQLException e, long updateCount, boolean sendSQLERRRM) throws DRDAProtocolException - Throws:
DRDAProtocolException
-
getSqlCode
Get the SQLCODE to send for an exception or a warning.
The client expects a negative SQLCODE for exceptions and a positive SQLCODE for warnings. SQLCODE 0 means there is no error or warning condition. SQLCODE is also used to encode the severity of the condition (as returned by
SQLException.getErrorCode()
).For warnings, the SQLCODE is 10000, which is identical to
ExceptionSeverity.WARNING_SEVERITY
.For exceptions, the SQLCODE is set to
-severity-1
, which allows all non-negative severity values to be encoded. (Derby only uses non-negative severity values in the first place.)- Parameters:
e
- the exception or warning to get the SQLCODE for- Returns:
- the value to send as SQLCODE
-
writeSQLCARD
private void writeSQLCARD(SQLException e, long updateCount, long rowCount) throws DRDAProtocolException - Throws:
DRDAProtocolException
-
writeNullSQLCARDobject
Write a null SQLCARD as an object- Throws:
DRDAProtocolException
-
writeSQLERRRM
Write SQLERRRM Instance Variables SVRCOD - Severity Code - required- Parameters:
severity
- severity of error- Throws:
DRDAProtocolException
-
writeCMDCHKRM
Write CMDCHKRM Instance Variables SVRCOD - Severity Code - required- Parameters:
severity
- severity of error- Throws:
DRDAProtocolException
-
getExceptionSeverity
Translate from Derby exception severity to SVRCOD- Parameters:
e
- SQLException
-
writeSQLCAGRP
private void writeSQLCAGRP(SQLException e, long 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- Throws:
DRDAProtocolException
-
writeSQLCAGRP
private void writeSQLCAGRP(byte[] sqlState, int sqlcode, long updateCount, long rowCount) throws DRDAProtocolException Same as writeSQLCAGRP, but optimized for the case when there is no real exception, i.e. the exception is null, or "End of data" 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:
sqlState
- SQLState (already converted to UTF8)sqlcode
- sqlcodeupdateCount
-rowCount
-- Throws:
DRDAProtocolException
-
buildSqlerrmc
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. Server sends the sqlerrmc using UTF8 encoding to the client. To get the message, client sends back information to the server calling SYSIBM.SQLCAMESSAGE (see Sqlca.getMessage). Several parameters are sent to this procedure including the locale, the sqlerrmc that the client received from the server. On server side, the procedure SQLCAMESSAGE in SystemProcedures then calls the MessageService.getLocalizedMessage to retrieve the localized error message. In MessageService.getLocalizedMessage the sqlerrmc that is passed in, is parsed to retrieve the message id. The value it uses to parse the MessageId is char value of 20, otherwise it uses the entire sqlerrmc as the message id. This messageId is then used to retrieve the localized message if present, to the client.- 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
Build preformatted SQLException text for severe exceptions or SQLExceptions that are not Derby exceptions. 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
Build Tokenized SQLERRMC to just send the tokenized arguments to the client. for a Derby SQLException or an SQLException thrown by user code. Message argument tokens are separated by SQLERRMC_TOKEN_DELIMITER Multiple messages are separated by SystemProcedures.SQLERRMC_MESSAGE_DELIMITER ...- Parameters:
se
- SQLException to print
-
buildDataTruncationSqlerrmc
Build the SQLERRMC for ajava.sql.DataTruncation
warning. Serialize all the fields of theDataTruncation
instance in the order in which they appear in the parameter list of the constructor.- Parameters:
dt
- theDataTruncation
instance to serialize- Returns:
- the SQLERRMC string with all fields of the warning
-
writeSQLCAXGRP
private void writeSQLCAXGRP(long updateCount, long rowCount, String sqlerrmc, 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 1024 SQLERRMSG_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 70 SQLERRMSG_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 70- Parameters:
sqlerrmc
- sqlcodenextException
- SQLException encountered- Throws:
DRDAProtocolException
-
writeSQLCAERRWARN
private void writeSQLCAERRWARN(long updateCount, long rowCount) Write the ERR and WARN part of the SQLCA- Parameters:
updateCount
-rowCount
-
-
writeSQLDIAGGRP
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
- Throws:
DRDAProtocolException
-
writeSQLDIAGCI
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
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
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, String sqlState, String dbname, 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, String sqlState, String dbname, 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
- Throws:
DRDAProtocolException
-
writeSQLDARD
private void writeSQLDARD(DRDAStatement stmt, boolean rtnOutput, SQLException e) throws DRDAProtocolException, 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
-
writeQRYDSC
private void writeQRYDSC(DRDAStatement stmt, boolean FDODSConly) throws DRDAProtocolException, SQLException Write QRYDSC - Query Answer Set Description- Parameters:
stmt
- DRDAStatement we are working onFDODSConly
- 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
-
writeSQLDTAGRP
private void writeSQLDTAGRP(DRDAStatement stmt, ResultSetMetaData rsmeta, ParameterMetaData pmeta, int colStart, int colEnd, boolean first) throws DRDAProtocolException, 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 statementrsmeta
- resultset meta datapmeta
- parameter meta data for CallableStatementcolStart
- starting column for group to sendcolEnd
- end column to sendfirst
- is this the first group- Throws:
DRDAProtocolException
SQLException
-
writeSQLDHROW
Holdability passed in as it can represent the holdability of the statement or a specific result set.- Parameters:
holdability
- HOLD_CURSORS_OVER_COMMIT or CLOSE_CURSORS_AT_COMMIT- Throws:
DRDAProtocolException
SQLException
-
writeQRYDTA
Write QRYDTA - Query Answer Set Data Contains some or all of the answer set data resulting from a query If the client is not using rowset processing, this routine attempts to pack as much data into the QRYDTA as it can. This may result in splitting the last row across the block, in which case when the client calls CNTQRY we will return the remainder of the row. Splitting a QRYDTA block is expensive, for several reasons: - extra logic must be run, on both client and server side - more network round-trips are involved - the QRYDTA block which contains the continuation of the split row is generally wasteful, since it contains the remainder of the split row but no additional rows. Since splitting is expensive, the server makes some attempt to avoid it. Currently, the server's algorithm for this is to compute the length of the current row, and to stop trying to pack more rows into this buffer if another row of that length would not fit. However, since rows can vary substantially in length, this algorithm is often ineffective at preventing splits. For example, if a short row near the end of the buffer is then followed by a long row, that long row will be split. It is possible to improve this algorithm substantially: - instead of just using the length of the previous row as a guide for whether to attempt packing another row in, use some sort of overall average row size computed over multiple rows (e.g., all the rows we've placed into this QRYDTA block, or all the rows we've process for this result set) - when we discover that the next row will not fit, rather than splitting the row across QRYDTA blocks, if it is relatively small, we could just hold the entire row in a buffer to place it entirely into the next QRYDTA block, or reset the result set cursor back one row to "unread" this row. - when splitting a row across QRYDTA blocks, we tend to copy data around multiple times. Careful coding could remove some of these copies. However, it is important not to over-complicate this code: it is better to be correct than to be efficient, and there have been several bugs in the split logic already. Instance Variables Byte string- Parameters:
stmt
- DRDA statement we are processing- Throws:
DRDAProtocolException
SQLException
-
writeFDODTA
This routine places some data into the current QRYDTA block using FDODTA (Formatted Data Object DaTA rules). There are 3 basic types of processing flow for this routine: - In normal non-rowset, non-scrollable cursor flow, this routine places a single row into the QRYDTA block and returns TRUE, indicating that the caller can call us back to place another row into the result set if he wishes. (The caller may need to send Externalized Data, which would be a reason for him NOT to place any more rows into the QRYDTA). - In ROWSET processing, this routine places an entire ROWSET of rows into the QRYDTA block and returns FALSE, indicating that the QRYDTA block is full and should now be sent. - In callable statement processing, this routine places the results from the output parameters of the called procedure into the QRYDTA block. This code path is really dramatically different from the other two paths and shares only a very small amount of common code in this routine. In all cases, it is possible that the data we wish to return may not fit into the QRYDTA block, in which case we call splitQRYDTA to split the data and remember the remainder data in the result set. Splitting the data is relatively rare in the normal cursor case, because our caller (writeQRYDTA) uses a coarse estimation technique to avoid calling us if he thinks a split is likely. The overall structure of this routine is implemented as two loops: - the outer "do ... while ... " loop processes a ROWSET, one row at a time. For non-ROWSET cursors, and for callable statements, this loop executes only once. - the inner "for ... i < numCols ..." loop processes each column in the current row, or each output parmeter in the procedure. Most column data is written directly inline in the QRYDTA block. Some data, however, is written as Externalized Data. This is commonly used for Large Objects. In that case, an Externalized Data Pointer is written into the QRYDTA block, and the actual data flows in separate EXTDTA blocks which are returned after this QRYDTA block.- Throws:
DRDAProtocolException
SQLException
-
getObjectForWriteFdoca
Get a column value of the specified type from a
ResultSet
, in a form suitable for being writted bywriteFdocaVal(int, java.lang.Object, int, int, int, boolean, org.apache.derby.impl.drda.DRDAStatement, boolean)
. For most types, this means just callingResultSet.getObject(int)
.The only exception currently is the data types representing dates and times, as they need to be fetched using the same
java.util.Calendar
aswriteFdocaVal(int, java.lang.Object, int, int, int, boolean, org.apache.derby.impl.drda.DRDAStatement, boolean)
uses when writing them (DERBY-4582).Note: Changes made in this method should also be made in the corresponding method for
CallableStatement
:getObjectForWriteFdoca(java.sql.CallableStatement, int, int)
.- Parameters:
rs
- the result set to fetch the object fromindex
- the column indexdrdaType
- the DRDA type of the object to fetch- Returns:
- an object with the value of the column
- Throws:
SQLException
- See Also:
-
getObjectForWriteFdoca
private Object getObjectForWriteFdoca(CallableStatement cs, int index, int drdaType) throws SQLException Get the value of an output parameter of the specified type from a
CallableStatement
, in a form suitable for being writted bywriteFdocaVal(int, java.lang.Object, int, int, int, boolean, org.apache.derby.impl.drda.DRDAStatement, boolean)
. For most types, this means just callingCallableStatement.getObject(int)
.This method should behave like the corresponding method for
ResultSet
, and changes made to one of these methods, must be reflected in the other method. SeegetObjectForWriteFdoca(java.sql.ResultSet, int, int)
for details.- Parameters:
cs
- the callable statement to fetch the object fromindex
- the parameter indexdrdaType
- the DRDA type of the object to fetch- Returns:
- an object with the value of the output parameter
- Throws:
SQLException
- See Also:
-
splitQRYDTA
private void splitQRYDTA(DRDAStatement stmt, int blksize) throws SQLException, DRDAProtocolException Split QRYDTA into blksize chunks This routine is called if the QRYDTA data will not fit. It writes as much data as it can, then stores the remainder in the result set. At some later point, when the client returns with a CNTQRY, we will call processLeftoverQRYDTA to handle that data. The interaction between DRDAConnThread and DDMWriter is rather complicated here. This routine gets called because DRDAConnThread realizes that it has constructed a QRYDTA message which is too large. At that point, we need to reclaim the "extra" data and hold on to it. To aid us in that processing, DDMWriter provides the routines getDSSLength, copyDSSDataToEnd, and truncateDSS. For some additional detail on this complex sub-protocol, the interested reader should study bug DERBY-491 and 492 at: http://issues.apache.org/jira/browse/DERBY-491 and http://issues.apache.org/jira/browse/DERBY-492- Parameters:
stmt
- DRDA statmentblksize
- size of query block- Throws:
SQLException
DRDAProtocolException
-
processLeftoverQRYDTA
private boolean processLeftoverQRYDTA(DRDAStatement stmt) throws SQLException, DRDAProtocolException Process remainder data resulting from a split. This routine is called at the start of building each QRYDTA block. Normally, it observes that there is no remainder data from the previous QRYDTA block, and returns FALSE, indicating that there was nothing to do. However, if it discovers that the previous QRYDTA block was split, then it retrieves the remainder data from the result set, writes as much of it as will fit into the QRYDTA block (hopefully all of it will fit, but the row may be very long), and returns TRUE, indicating that this QRYDTA block has been filled with remainder data and should now be sent immediately.- Throws:
SQLException
DRDAProtocolException
-
doneData
Done data Send SQLCARD for the end of the data- Parameters:
stmt
- DRDA statementrs
- Result set- Throws:
DRDAProtocolException
SQLException
-
positionCursor
private boolean positionCursor(DRDAStatement stmt, ResultSet rs) throws SQLException, DRDAProtocolException Position cursor for insensitive scrollable cursors- Parameters:
stmt
- DRDA statementrs
- Result set- Throws:
SQLException
DRDAProtocolException
-
writeSQLDAGRP
private void writeSQLDAGRP(ResultSetMetaData rsmeta, ParameterMetaData pmeta, int elemNum, boolean rtnOutput) throws DRDAProtocolException, 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 datapmeta
- parameter meta dataelemNum
- 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
-
writeVCMorVCS
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(ResultSetMetaData rsmeta, ParameterMetaData pmeta, int jdbcElemNum, boolean rtnOutput) throws DRDAProtocolException, SQLException Write SQLUDTGRP (SQL Descriptor User-Defined Type Group Descriptor) This is the format from the DRDA spec, Volume 1, section 5.6.4.10. However, this format is not rich enough to carry the information needed by JDBC. This format does not have a subtype code for JAVA_OBJECT and this format does not convey the Java class name needed by ResultSetMetaData.getColumnClassName(). SQLUDXTYPE; DRDA TYPE I4; ENVLID 0x02; Length Override 4 Constants which map to java.sql.Types constants DISTINCT, STRUCT, and REF. But DRDA does not define a constant which maps to java.sql.Types.JAVA_OBJECT. SQLUDTRDB; DRDA TYPE VCS; ENVLID 0x32; Length Override 255 Database name. SQLUDTSCHEMA_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 255 SQLUDTSCHEMA_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 255 Schema name. One of the above. SQLUDTNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 255 SQLUDTNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 255 Unqualified UDT name. One of the above. Instead, we use the following format and only for communication between Derby servers and Derby clients which are both at version 10.6 or higher. For all other client/server combinations, we send null. SQLUDTNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override 255 SQLUDTNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override 255 Fully qualified UDT name. One of the above. SQLUDTCLASSNAME_m; DRDA TYPE VCM; ENVLID 0x3E; Length Override FdocaConstants.LONGVARCHAR_MAX_LEN SQLUDTCLASSNAME_s; DRDA TYPE VCS; ENVLID 0x32; Length Override FdocaConstants.LONGVARCHAR_MAX_LEN Name of the Java class bound to the UDT. One of the above.- Parameters:
rsmeta
- resultset meta datapmeta
- parameter meta datajdbcElemNum
- 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
-
writeSQLDOPTGRP
private void writeSQLDOPTGRP(ResultSetMetaData rsmeta, ParameterMetaData pmeta, int jdbcElemNum, boolean rtnOutput) throws DRDAProtocolException, SQLException - Throws:
DRDAProtocolException
SQLException
-
writeSQLDXGRP
private void writeSQLDXGRP(ResultSetMetaData rsmeta, ParameterMetaData pmeta, int jdbcElemNum, boolean rtnOutput) throws DRDAProtocolException, SQLException - Throws:
DRDAProtocolException
SQLException
-
writeFdocaVal
protected void writeFdocaVal(int index, Object val, int drdaType, int precision, int scale, boolean valNull, DRDAStatement stmt, boolean isParam) throws DRDAProtocolException, SQLException Write Fdoca Value to client- Parameters:
index
- Index of column being returnedval
- Value to write to clientdrdaType
- FD:OCA DRDA Type from FdocaConstantsprecision
- Precisionstmt
- Statement being processedisParam
- True when writing a value for a procedure parameter- Throws:
DRDAProtocolException
SQLException
- See Also:
-
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 typevalNull
- true if this is a null value. False otherwise
-
formatDate
Convert ajava.sql.Date
to a string with the format expected by the client.- Parameters:
date
- the date to format- Returns:
- a string on the format YYYY-MM-DD representing the date
- See Also:
-
formatTime
Convert ajava.sql.Time
to a string with the format expected by the client.- Parameters:
time
- the time to format- Returns:
- a string on the format HH:MM:SS representing the time
- See Also:
-
formatTimestamp
Convert ajava.sql.Timestamp
to a string with the format expected by the client.- Parameters:
ts
- the timestamp to format- Returns:
- a string on the format YYYY-MM-DD-HH.MM.SS.ffffff[fff]
- See Also:
-
padInt
private void padInt(char[] buf, int offset, int length, int value) Insert an integer into a char array and pad it with leading zeros if its string representation is shorter thanlength
characters.- Parameters:
buf
- the char arrayoffset
- where in the array to start inserting the valuelength
- the desired length of the inserted stringvalue
- the integer value to insert
-
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
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
Seen too many of this code point- Parameters:
codePoint
- code point which has been duplicated- Throws:
DRDAProtocolException
-
tooBig
Object too big- Parameters:
codePoint
- code point with too big object- Throws:
DRDAProtocolException
-
invalidClient
Invalid non-derby client tried to connect. thrown a required Value not found error and log a message to derby.log- Parameters:
prdid
- product id that does not match DNC- Throws:
DRDAProtocolException
-
requiredValueNotFound
Required value not found.- Parameters:
codePoint
- code point with invalid value- Throws:
DRDAProtocolException
-
badObjectLength
Object length not allowed- Parameters:
codePoint
- code point with bad object length- Throws:
DRDAProtocolException
-
rdbNotFound
RDB not found- Parameters:
rdbnam
- name of database- Throws:
DRDAProtocolException
-
invalidValue
Invalid value for this code point- Parameters:
codePoint
- code point value- Throws:
DRDAProtocolException
-
invalidCodePoint
Invalid codepoint for this command- Parameters:
codePoint
- code point value- Throws:
DRDAProtocolException
-
codePointNotSupported
Don't support this code point- Parameters:
codePoint
- code point value- Throws:
DRDAProtocolException
-
valueNotSupported
Don't support this value- Parameters:
codePoint
- code point value- Throws:
DRDAProtocolException
-
verifyRequiredObject
Verify that the code point is the required code point- Parameters:
codePoint
- code point we havereqCodePoint
- 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 havereqCodePoint
- code point required at this time- Throws:
DRDAProtocolException
-
rdbnamMismatch
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
Handle Exceptions - write error protocol if appropriate and close session or thread as appropriate -
sendProtocolException
Notice the client about a protocol error.- Parameters:
de
-DRDAProtocolException
to be sent
-
sendUnexpectedException
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
Send string to console- Parameters:
value
- - value to print on console
-
traceEXTDTARead
private void traceEXTDTARead(int drdaType, int index, EXTDTAReaderInputStream stream, boolean streamLOB, String encoding) Sends a trace string to the console when reading an EXTDTA value (if tracing is enabled).- Parameters:
drdaType
- the DRDA type of the EXTDTA valueindex
- the one-based parameter indexstream
- the stream being readstreamLOB
- whether or not the value is being streamed as the last parameter value in the DRDA protocol flowencoding
- the encoding of the data, if any
-
showmem
public static void showmem()Show runtime memory -
convertToHexString
convert byte array to a Hex string- Parameters:
buf
- buffer to convert- Returns:
- hex string representation of byte array
-
checkValidTypDefNam
check that the given typdefnam is acceptable- Parameters:
typdefnam
-- Throws:
DRDAProtocolException
-
checkLength
Check that the length is equal to the required length for this codepoint- Parameters:
codepoint
- codepoint we are checkingreqlen
- required length- Throws:
DRDAProtocolException
-
readBoolean
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
-
initializeDatabase
Create a new database and intialize the DRDAConnThread database.- Parameters:
dbname
- database name to initialize. If dbnam is non null, add database to the current session
-
setDatabase
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
- Throws:
SQLException
DRDAProtocolException
-
checkWarning
private void checkWarning(Connection conn, Statement stmt, ResultSet rs, long updateCount, boolean alwaysSend, boolean sendWarn) throws DRDAProtocolException, SQLException Check SQLWarning and write SQLCARD as needed.- Parameters:
conn
- connection to checkstmt
- statement to checkrs
- result set to checkupdateCount
- update count to include in SQLCARDalwaysSend
- whether always send SQLCARD regardless of the existance of warningssendWarn
- whether to send any warnings or not.- Throws:
DRDAProtocolException
SQLException
-
hasSession
boolean hasSession() -
getBytesRead
long getBytesRead() -
getBytesWritten
long getBytesWritten() -
buildRuntimeInfo
-
finalizeChain
Finalize the current DSS chain and send it if needed.- Throws:
DRDAProtocolException
-
validateSecMecUSRSSBPWD
Validate SECMEC_USRSSBPWD (Strong Password Substitute) can be used as DRDA security mechanism. Here we check that the target server can support SECMEC_USRSSBPWD security mechanism based on the environment, application requester's identity (PRDID) and connection URL. IMPORTANT NOTE: -------------- SECMEC_USRSSBPWD is ONLY supported by the target server if: - current authentication provider is Derby BUILTIN or NONE. (database / system level) (Phase I) - database-level password must have been encrypted with the SHA-1 based authentication scheme - Application requester is 'DNC' (Derby Network Client) (Phase I)- Returns:
- security check code - 0 if everything O.K.
- Throws:
DRDAProtocolException
-
closeStream
Close a stream.- Parameters:
stream
- the stream to close (possiblynull
)- Throws:
SQLException
- wrapped around anIOException
if closing the stream failed
-
convertAsByteArrayInputStream
private static InputStream convertAsByteArrayInputStream(EXTDTAReaderInputStream stream) throws IOException - Throws:
IOException
-
setAsCharacterStream
private static void setAsCharacterStream(DRDAStatement stmt, int i, EXTDTAReaderInputStream extdtaStream, boolean streamLOB, String encoding) throws IOException, SQLException Sets the specified character EXTDTA parameter of the embedded statement.- Parameters:
stmt
- the DRDA statement to usei
- the one-based index of the parameterextdtaStream
- the EXTDTA stream to read data fromstreamLOB
- whether or not the stream content is streamed as the last value in the DRDA protocol flowencoding
- the encoding of the EXTDTA stream- Throws:
IOException
- if reading from the stream failsSQLException
- if setting the stream fails
-
setAsBinaryStream
private static void setAsBinaryStream(DRDAStatement stmt, int index, EXTDTAReaderInputStream stream, boolean streamLOB) throws IOException, SQLException Sets the specified binary EXTDTA parameter of the embedded statement.- Parameters:
stmt
- the DRDA statement to useindex
- the one-based index of the parameterstream
- the EXTDTA stream to read data fromstreamLOB
- whether or not the stream content is streamed as the last value in the DRDA protocol flow- Throws:
IOException
- if reading from the stream failsSQLException
- if setting the stream fails
-
getMonitor
Privileged Monitor lookup. Must be private so that user code can't call this entry point. -
findService
Privileged service lookup. Must be private so that user code can't call this entry point.
-