⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 netstatementrequest.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    try {                        ba = s.getBytes("UTF-8");                        bais = new java.io.ByteArrayInputStream(ba);                        Clob c = new Clob(netAgent_, bais, "UTF-8", ba.length);                        // inputRow[i] = c;                        // Place the new Lob in the promototedParameter_ collection for                        // NetStatementRequest use                        promototedParameters_.put(new Integer(i), c);                        lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NLOBCMIXED;                        lidAndLengths[i][1] = buildPlaceholderLength(c.length());                    } catch (java.io.UnsupportedEncodingException e) {                        throw new SqlException(netAgent_.logWriter_, e, "Error in building String parameter: throwable attached");                    }                }                break;            case java.sql.Types.BINARY:            case java.sql.Types.VARBINARY:                byte[] ba = (byte[]) inputRow[i];                if (ba == null) {                    lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NVARBYTE;                    lidAndLengths[i][1] = 32767;                } else if (ba.length <= 32767) {                    lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NVARBYTE;                    lidAndLengths[i][1] = 32767;                } else {                    // Promote to a BLOB. Only reach this path in the absence of describe information.                    Blob b = new Blob(ba, netAgent_, 0);                    // inputRow[i] = b;                    // Place the new Lob in the promototedParameter_ collection for                    // NetStatementRequest use                    promototedParameters_.put(new Integer(i), b);                    lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NLOBBYTES;                    lidAndLengths[i][1] = buildPlaceholderLength(ba.length);                }                break;            case java.sql.Types.LONGVARBINARY:                ba = (byte[]) inputRow[i];                if (ba == null) {                    lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NLONGVARBYTE;                    lidAndLengths[i][1] = 32767;                } else if (ba.length <= 32767) {                    lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NLONGVARBYTE;                    lidAndLengths[i][1] = 32767;                } else {                    // Promote to a BLOB. Only reach this path in the absensce of describe information.                    Blob b = new Blob(ba, netAgent_, 0);                    // inputRow[i] = b;                    // Place the new Lob in the promototedParameter_ collection for                    // NetStatementRequest use                    promototedParameters_.put(new Integer(i), b);                    lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NLOBBYTES;                    lidAndLengths[i][1] = buildPlaceholderLength(ba.length);                }                break;            case java.sql.Types.BLOB:                java.sql.Blob b = (java.sql.Blob) inputRow[i];                if (b == null) {                    lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NLOBBYTES;                    lidAndLengths[i][1] =                            buildPlaceholderLength(parameterMetaData.sqlLength_[i]);                } else {                    lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NLOBBYTES;                    try {                        lidAndLengths[i][1] = buildPlaceholderLength(b.length());                    } catch (java.sql.SQLException e) {                        if (!(e instanceof org.apache.derby.client.am.SqlException)) {                            SqlException toThrow =                                    new SqlException(netAgent_.logWriter_, "Error obtaining length of external blob object, exception follows. ");                            toThrow.setNextException(e);                            throw toThrow;                        } else {                            throw new SqlException(netAgent_.logWriter_, e, "Error obtaining length of blob object, exception follows. ");                        }                    }                }                break;            case java.sql.Types.CLOB:                {                    // use columnMeta.singleMixedByteOrDouble_ to decide protocolType                    java.sql.Clob c = (java.sql.Clob) inputRow[i];                    boolean isExternalClob = !(c instanceof org.apache.derby.client.am.Clob);                    long lobLength = 0;                    if (c == null) {                        lobLength = parameterMetaData.sqlLength_[i];                    } else if (isExternalClob) {                        try {                            lobLength = c.length();                        } catch (java.sql.SQLException e) {                            if (!(e instanceof org.apache.derby.client.am.SqlException)) {                                SqlException toThrow =                                        new SqlException(netAgent_.logWriter_, "Error obtaining length of external clob object, exception follows. ");                                toThrow.setNextException(e);                                throw toThrow;                            } else {                                throw new SqlException(netAgent_.logWriter_, e, "Error obtaining length of clob object, exception follows. ");                            }                        }                    } else {                        lobLength = ((Clob) c).length();                    }                    if (c == null) {                        lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NLOBCMIXED;                        lidAndLengths[i][1] = buildPlaceholderLength(lobLength);                    } else if (isExternalClob) {                        lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NLOBCDBCS;                        lidAndLengths[i][1] = buildPlaceholderLength(lobLength);                    } else if (((Clob) c).isCharacterStream()) {                        lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NLOBCDBCS;                        lidAndLengths[i][1] = buildPlaceholderLength(lobLength);                    } else if (((Clob) c).isUnicodeStream()) {                        lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NLOBCMIXED;                        lidAndLengths[i][1] = buildPlaceholderLength(lobLength);                    } else if (((Clob) c).isAsciiStream()) {                        lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NLOBCSBCS;                        lidAndLengths[i][1] = buildPlaceholderLength(lobLength);                    } else if (((Clob) c).isString()) {                        lidAndLengths[i][0] = FdocaConstants.PROTOCOL_TYPE_NLOBCMIXED;                        lidAndLengths[i][1] = buildPlaceholderLength(((Clob) c).getUTF8Length());                    }                }                break;            default :                throw new SqlException(netAgent_.logWriter_, "unrecognized sql type");            }            if (!parameterMetaData.nullable_[i]) {                lidAndLengths[i][0]--;            }        }        return overrideMap;    }    private int buildPlaceholderLength(long totalLength) {        if (totalLength < 0x7fff) {            return 0x8002; // need 2 bytes        } else if (totalLength < 0x7fffffff) {            return 0x8004; // need 4 bytes        } else if (totalLength < 0x7fffffffffffL) {            return 0x8006;        } else {            return 0x8008; // need 8 bytes        }    }    // Output Expected indicates wheterh the requester expects the target    // SQLAM to return output with an SQLDTARD reply data object    // as a result of the execution of the referenced SQL statement.    // this is a single byte.    // there are two possible enumerated values:    // 0x'F1' (CodePoint.TRUE) - for true indicating the requester expects output    // 0x'F0' (CodePoint.FALSE) - for false indicating the requeser does not expect output    // 0x'F0' is the default.    //    // preconditions:    //   sqlam must support this parameter on the command, method will not check.    private void buildOUTEXP(boolean outputExpected) throws SqlException {        if (outputExpected) {            writeScalar1Byte(CodePoint.OUTEXP, CodePoint.TRUE);        }    }    // Maximum Number of Extra Blocks specifies a limit on the number of extra    // blocks of answer set data per result set that the requester is capable of    // receiveing.    // this value must be able to be contained in a two byte signed number.    // there is a minimum value of 0.    // a zero indicates that the requester is not capable of receiving extra    // query blocks of answer set data.    // there is a SPCVAL of -1.    // a value of -1 indicates that the requester is capable of receiving    // the entire result set.    //    // preconditions:    //   sqlam must support this parameter on the command, method will not check.    void buildMAXBLKEXT(int maxNumOfExtraBlocks) throws SqlException {        if (maxNumOfExtraBlocks != 0) {            writeScalar2Bytes(CodePoint.MAXBLKEXT, maxNumOfExtraBlocks);        }    }    // preconditions:    void buildQRYROWSET(int fetchSize) throws SqlException {        writeScalar4Bytes(CodePoint.QRYROWSET, fetchSize);    }    // The Procedure Name.    // The default value of PRCNAM is the procedure name value contained    // within the section identified by the pkgnamcsn parameter.  If that    // value is null, then the prcnam parameter must be specified.    // it has a max length of 255.    // the prcnam is required on commands if the procedure name is    // specified by a host variable.    // the default value is the procedure name contained in the section    // specified by the pkgnamcsn parameter on the EXCSQLSTT command.    //    // preconditions:    //   sqlam must support this parameter for the command, method will not check.    //   prcnam can not be null, SQLException will be thrown    //   prcnam can not be 0 length or > 255 length, SQLException will be thrown.    private void buildPRCNAM(String prcnam) throws SqlException {        if (prcnam == null) {            throw new SqlException(netAgent_.logWriter_, "null procedure name not supported");        }        int prcnamLength = prcnam.length();        if ((prcnamLength == 0) || (prcnamLength > 255)) {            throw new SqlException(netAgent_.logWriter_, "procedure name length, " + prcnamLength + ", is not allowed.");        }        writeScalarString(CodePoint.PRCNAM, prcnam);    }    // Query Block Size specifies the query block size for the reply    // data objects and the reply messages being returned from this command.    // this is a 4 byte unsigned binary number.    // the sqlam 6 min value is 512 and max value is 32767.    // this value was increased in later sqlam levels.    // until the code is ready to support larger query block sizes,    // it will always use DssConstants.MAX_DSS_LEN which is 32767.    //    // preconditions:    //   sqlam must support this parameter for the command, method will not check.    void buildQRYBLKSZ() throws SqlException {        writeScalar4Bytes(CodePoint.QRYBLKSZ, DssConstants.MAX_DSS_LEN);    }    // Maximum Result Set Count specifies a limit on the number of result sets    // the requester is capable of receiving as reply data in response to an ECSQLSTT    // command that invokes a stored procedure.  If the stored procedure generates    // more than MAXRSLCNT result sets, then the target system returns at most, the first    // MAXRSLCNT of these result sets.  The stored procedure defines the order    // in which the target system returns result sets.    // this is s two byte signed binary number.    // it has a min value of 0 which indicates the requester is not capable    // of receiving result sets as reply data in response to the command.    // a special value, -1 (CodePoint.MAXRSLCNT_NOLIMIT = 0xffff), indicates the    // requester is capable of receiving all result sets in response the EXCSQLSTT.    //    // preconditions:    //   sqlam must support this parameter for the command, method will not check.    //   the value must be in correct range (-1 to 32767), method will not check.    private void buildMAXRSLCNT(int maxResultSetCount) throws SqlException {        if (maxResultSetCount == 0) {            return;        }        writeScalar2Bytes(CodePoint.MAXRSLCNT, maxResultSetCount);    }    // RDB Commit Allowed specifies whether an RDB should allow the processing of any    // commit or rollback operations that occure during execution of a statement.    // True allow the processing of commits and rollbacks    private void buildRDBCMTOK() throws SqlException {        writeScalar1Byte(CodePoint.RDBCMTOK, CodePoint.TRUE);    }    // Result Set Flags is a single byte where each bit it a boolean flag.    // It specifies wheter the requester desires the server to return name,    // label and comment information for the columns of result sets generated by the command.    // The default is b'00000000'.    // columnNamesRequired    //    false means the requester does not desire column names returned.    //    true means the requester desires column names returned.    // columnLabelsRequired    //    false means the requester does not desire column labels returned.    //    true means the requester desires column labels returned.    // columnCommentsRequired    //    false means the requester does not desire column comments returned.    //    true means the requester desired column comments returned.    // cantProcessAnswerSetData    //    false means that for each result set, the requester expects the command    //    to return an FDOCA description of the answer set data and to possibly    //    return answer set data.  the block containing the end of the d

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -