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

📄 netconnectionrequest.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                     String password,                     byte[] sectkn,                     byte[] sectkn2) throws SqlException {        createCommand();        markLengthBytes(CodePoint.SECCHK);        // always send the negotiated security mechanism for the connection.        buildSECMEC(secmec);        // the rdbnam will be built and sent.  different sqlam levels support        // different lengths.  at this point the length has been checked against        // the maximum allowable length.  so write the bytes and padd up to the        // minimum length if needed.        buildRDBNAM(rdbnam);        if (user != null) {            buildUSRID(user);        }        if (password != null) {            buildPASSWORD(password);        }        if (sectkn != null) {            buildSECTKN(sectkn);        }        if (sectkn2 != null) {            buildSECTKN(sectkn2);        }        updateLengthBytes();    }    // The Access RDB (ACCRDB) command makes a named relational database (RDB)    // available to a requester by creating an instance of an SQL application    // manager.  The access RDB command then binds the created instance to the target    // agent and to the RDB. The RDB remains available (accessed) until    // the communications conversation is terminate.    void buildACCRDB(String rdbnam,                     boolean readOnly,                     byte[] crrtkn,                     byte[] prddta,                     Typdef typdef) throws SqlException {        createCommand();        markLengthBytes(CodePoint.ACCRDB);        // the relational database name specifies the name of the rdb to        // be accessed.  this can be different sizes depending on the level of        // support.  the size will have ben previously checked so at this point just        // write the data and pad with the correct number of bytes as needed.        // this instance variable is always required.        buildRDBNAM(rdbnam);        // the rdb access manager class specifies an instance of the SQLAM        // that accesses the RDB.  the sqlam manager class codepoint        // is always used/required for this.  this instance variable        // is always required.        buildRDBACCCL();        // product specific identifier specifies the product release level        // of this driver.  see the hard coded value in the NetConfiguration class.        // this instance variable is always required.        buildPRDID();        // product specific data.  this is an optional parameter which carries        // product specific information.  although it is optional, it will be        // sent to the server.  use the first byte to determine the number        // of the prddta bytes to write to the buffer. note: this length        // doesn't include itself so increment by it by 1 to get the actual        // length of this data.        buildPRDDTA(prddta);        // the typdefnam parameter specifies the name of the data type to data representation        // mappings used when this driver sends command data objects.        buildTYPDEFNAM(typdef.getTypdefnam());        if (crrtkn == null) {            netAgent_.netConnection_.constructCrrtkn();        }        buildCRRTKN(netAgent_.netConnection_.crrtkn_);        // This specifies the single-byte, double-byte        // and mixed-byte CCSIDs of the Scalar Data Arrays (SDAs) in the identified        // data type to the data representation mapping definitions.  This can        // contain 3 CCSIDs.  The driver will only send the ones which were set.        buildTYPDEFOVR(typdef.isCcsidSbcSet(),                typdef.getCcsidSbc(),                typdef.isCcsidDbcSet(),                typdef.getCcsidDbc(),                typdef.isCcsidMbcSet(),                typdef.getCcsidMbc());        // RDB allow update is an optional parameter which indicates        // whether the RDB allows the requester to perform update operations        // in the RDB.  If update operations are not allowed, this connection        // is limited to read-only access of the RDB resources.        buildRDBALWUPD(readOnly);        // the Statement Decimal Delimiter (STTDECDEL),        // Statement String Delimiter (STTSTRDEL),        // and Target Default Value Return (TRGDFTRT) are all optional        // instance variables which will not be sent to the server.        // the command and the dss are complete so make the call to notify        // the request object.        updateLengthBytes();    }    void buildSYNCCTLMigrate() throws SqlException {    }    void buildSYNCCTLCommit(int xaFlags, Xid xid) throws SqlException {    }    void buildSYNCCTLRollback(int xaFlags) throws SqlException {    }    // The External Name is the name of the job, task, or process on a    // system for which a DDM server is active.    private void buildEXTNAM(String extnam) throws SqlException {        int extnamTruncateLength = Utils.min(extnam.length(),                NetConfiguration.EXTNAM_MAXSIZE);        writeScalarString(CodePoint.EXTNAM,                extnam.substring(0, extnamTruncateLength));    }    // Server Name is the name of the DDM server.    private void buildSRVNAM(String srvnam) throws SqlException {        int srvnamTruncateLength = Utils.min(srvnam.length(),                NetConfiguration.SRVNAM_MAXSIZE);        writeScalarString(CodePoint.SRVNAM,                srvnam.substring(0, srvnamTruncateLength));    }    // Server Product Release Level String specifies the product    // release level of a DDM server.    private void buildSRVRLSLV() throws SqlException {        // Hard-coded to ClientDNC 1.0 for dnc 1.0.        writeScalarString(CodePoint.SRVRLSLV, NetConfiguration.SRVRLSLV);    }    private void buildSRVCLSNM() throws SqlException {        // Server class name is hard-coded to QDERBY/JVM for dnc.        writeScalarString(CodePoint.SRVCLSNM, NetConfiguration.SRVCLSNM_JVM);    }    // Precondition: valid secmec is assumed.    private void buildSECMEC(int secmec) throws SqlException {        writeScalar2Bytes(CodePoint.SECMEC, secmec);    }    // Relational Database Name specifies the name of a relational database    // of the server.    // if length of RDB name <= 18 characters, there is not change to the format    // of the RDB name.  The length of the RDBNAM remains fixed at 18 which includes    // any right bland padding if necessary.    // if length of the RDB name is > 18 characters, the length of the RDB name is    // identical to the length of the RDB name.  No right blank padding is required.    private void buildRDBNAM(String rdbnam) throws SqlException {        // since this gets built more than once on the connect flow,        // see if we can optimize        int rdbnamLength = rdbnam.length();        if (rdbnamLength <= NetConfiguration.PKG_IDENTIFIER_FIXED_LEN) {            writeScalarPaddedString(CodePoint.RDBNAM,                    rdbnam,                    NetConfiguration.PKG_IDENTIFIER_FIXED_LEN);  // minimum length of RDBNAM        } else {            if (rdbnamLength <= NetConfiguration.PKG_IDENTIFIER_MAX_LEN) {                writeScalarString(CodePoint.RDBNAM, rdbnam);            } else {                throw new SqlException(netAgent_.logWriter_, "Length of the Relational Database Name, " +                        rdbnam +                        ", exceeds maximum size allowed for PROTOCOL Connection.");// +            }            //"at SQLAM level " + netAgent_.targetSqlam_);        }    }    private void buildSECTKN(byte[] sectkn) throws SqlException {        if (sectkn.length > NetConfiguration.SECTKN_MAXSIZE) {            throw new SqlException(netAgent_.logWriter_, "bug check: sectkn too long");        }        writeScalarBytes(CodePoint.SECTKN, sectkn);    }    private void buildUSRID(String usrid) throws SqlException {        int usridLength = usrid.length();        if ((usridLength == 0) || (usridLength > NetConfiguration.USRID_MAXSIZE)) {            throw new SqlException(netAgent_.logWriter_, "userid length, " + usridLength + ", is not allowed.");        }        writeScalarString(CodePoint.USRID, usrid);    }    private void buildPASSWORD(String password) throws SqlException {        int passwordLength = password.length();        if ((passwordLength == 0) || (passwordLength > NetConfiguration.PASSWORD_MAXSIZE)) {            throw new SqlException(netAgent_.logWriter_, "password length, " + passwordLength + ", is not allowed.");        }        if (netAgent_.logWriter_ != null) {            // remember the position of password in order to            // mask it out in trace (see Request.sendBytes()).            passwordIncluded_ = true;            passwordStart_ = offset_ + 4;            passwordLength_ = passwordLength;        }        writeScalarString(CodePoint.PASSWORD, password);    }    private void buildRDBACCCL() throws SqlException {        writeScalar2Bytes(CodePoint.RDBACCCL, CodePoint.SQLAM);    }    private void buildPRDID() throws SqlException {        writeScalarString(CodePoint.PRDID, NetConfiguration.PRDID);  // product id is hard-coded to DNC01000 for dnc 1.0.    }    private void buildPRDDTA(byte[] prddta) throws SqlException {        int prddtaLength = (prddta[NetConfiguration.PRDDTA_LEN_BYTE] & 0xff) + 1;        writeScalarBytes(CodePoint.PRDDTA, prddta, 0, prddtaLength);    }    private void buildTYPDEFNAM(String typdefnam) throws SqlException {        writeScalarString(CodePoint.TYPDEFNAM, typdefnam);    }    void buildTYPDEFOVR(boolean sendCcsidSbc,                        int ccsidSbc,                        boolean sendCcsidDbc,                        int ccsidDbc,                        boolean sendCcsidMbc,                        int ccsidMbc) throws SqlException {        markLengthBytes(CodePoint.TYPDEFOVR);        // write the single-byte ccsid used by this driver.        if (sendCcsidSbc) {            writeScalar2Bytes(CodePoint.CCSIDSBC, ccsidSbc);        }        // write the double-byte ccsid used by this driver.        if (sendCcsidDbc) {            writeScalar2Bytes(CodePoint.CCSIDDBC, ccsidDbc);        }        // write the mixed-byte ccsid used by this driver        if (sendCcsidMbc) {            writeScalar2Bytes(CodePoint.CCSIDMBC, ccsidMbc);        }        updateLengthBytes();    }    private void buildMGRLVLLS(int agent,                               int sqlam,                               int rdb,                               int secmgr,                               int xamgr,                               int syncptmgr,                               int rsyncmgr) throws SqlException {        markLengthBytes(CodePoint.MGRLVLLS);        // place the managers and their levels in the buffer        writeCodePoint4Bytes(CodePoint.AGENT, agent);        writeCodePoint4Bytes(CodePoint.SQLAM, sqlam);        writeCodePoint4Bytes(CodePoint.RDB, rdb);        writeCodePoint4Bytes(CodePoint.SECMGR, secmgr);        if (netAgent_.netConnection_.isXAConnection()) {            if (xamgr != NetConfiguration.MGRLVL_NA) {                writeCodePoint4Bytes(CodePoint.XAMGR, xamgr);            }            if (syncptmgr != NetConfiguration.MGRLVL_NA) {                writeCodePoint4Bytes(CodePoint.SYNCPTMGR, syncptmgr);            }            if (rsyncmgr != NetConfiguration.MGRLVL_NA) {                writeCodePoint4Bytes(CodePoint.RSYNCMGR, rsyncmgr);            }        }        updateLengthBytes();    }    private void buildCRRTKN(byte[] crrtkn) throws SqlException {        writeScalarBytes(CodePoint.CRRTKN, crrtkn);    }    private void buildRDBALWUPD(boolean readOnly) throws SqlException {        if (readOnly) {            writeScalar1Byte(CodePoint.RDBALWUPD, CodePoint.FALSE);        }    }}

⌨️ 快捷键说明

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