private void setRdbName(String dbname) { Database d = session.getDatabase(dbname); if (d == null) { addDatabase(dbname); } else { // reset database for connection re-use // DERBY-3596 // If we are reusing resources for a new physical // connection, reset the database object. If the client // is in the process of creating a new logical // connection only, don't reset the database object. if (!deferredReset) { d.reset(); } database = d; } }
/** * Build preformatted SQLException text * for severe exceptions or SQLExceptions that are not EmbedSQLExceptions. * Just send the message text localized to the server locale. * * @param se SQLException for which to build SQLERRMC * @return preformated message text * with messages separted by SQLERRMC_PREFORMATED_MESSAGE_DELIMITER * */ private String buildPreformattedSqlerrmc(SQLException se) { if (se == null) return ""; StringBuilder sb = new StringBuilder(); // GemStone changes BEGIN // prepend the server/thread information addServerInformation(sb); // GemStone changes END // String buffer to build up message do { sb.append(se.getLocalizedMessage()); se = se.getNextException(); if (se != null) sb.append(ClientSharedData.SQLERRMC_PREFORMATTED_MESSAGE_DELIMITER + "SQLSTATE: " + se.getSQLState()); } while (se != null); return sb.toString(); }
trace("Starting new connection thread"); while(!closed()) session = server.getNextSession(session); if (session == null) close(); if (closed()) break; if (session != prevSession) initializeForSession(); sessionInitialState(); if (session == null) break; processCommands(); } catch (DRDASocketTimeoutException ste) { currentTimeSlice = getTimeSlice(); } while ((currentTimeSlice <= 0) || (System.currentTimeMillis() - timeStart < currentTimeSlice)); agentError("Session in invalid state:" + session.state); closeSession();
/** * Check that the length is equal to the required length for this codepoint * * @param codepoint codepoint we are checking * @param reqlen required length * * @exception DRDAProtocolException */ private void checkLength(int codepoint, int reqlen) throws DRDAProtocolException { long len = reader.getDdmLength(); if (len < reqlen) badObjectLength(codepoint); else if (len > reqlen) tooBig(codepoint); } /**
/** * Read encoded string value * @param length - length of string to read * @return value * * @exception DRDProtocolException */ protected String readString (int length, String encoding) throws DRDAProtocolException { ensureBLayerDataInBuffer (length, ADJUST_LENGTHS); String s = null; try { s = new String (buffer, pos, length, encoding); } catch (java.io.UnsupportedEncodingException e) { agent.agentError("UnsupportedEncodingException in readString, encoding = " + encoding); e.printStackTrace(agent.getServer().logWriter); } pos += length; return s; }
/** * 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 * * @return string value */ private String parseVCMorVCS() throws DRDAProtocolException { String strVal = null; int vcm_length = reader.readNetworkShort(); if (vcm_length > 0) strVal = parseCcsidMBC(vcm_length); int vcs_length = reader.readNetworkShort(); if (vcs_length > 0) { if (strVal != null) agentError ("Both VCM and VCS have lengths > 0"); strVal = parseCcsidSBC(vcs_length); } return strVal; } /**
verifyInOrderACCSEC_SECCHK(codePoint,session.getRequiredSecurityCodepoint()); stmt = parseCNTQRY(); if (stmt != null) writeQRYDTA(stmt); writeENDQRYRM(CodePoint.SVRCOD_WARNING); writeNullSQLCARDobject(); checkWarning(null, null, stmt.getResultSet(), 0, false, sendWarningsOnCNTQRY); writePBSD(); cleanUpAndCloseResultSet(stmt, e, writerMark); updateCount = parseEXCSQLIMM(); writeRDBUPDRM(); checkWarning(null, database.getDefaultStatement().getStatement(), null, updateCount, true, true); writePBSD(); } catch (SQLException e) writeSQLCARDs(e, 0); errorInChain(e); if (parseEXCSQLSET())
copyToRequired(ACCRDB_REQUIRED); reader.markCollection(); codePoint = reader.getCodePoint(); checkLength(CodePoint.RDBACCCL, 2); int sqlam = reader.readNetworkShort(); if (this.trace) trace("RDBACCCL = " + sqlam); invalidValue(CodePoint.RDBACCCL); removeFromRequired(CodePoint.RDBACCCL); break; database.crrtkn = reader.readBytes(); if (this.trace) trace("crrtkn " + convertToHexString(database.crrtkn)); removeFromRequired(CodePoint.CRRTKN); int l = database.crrtkn.length; if (l > CodePoint.MAX_NAME) tooBig(CodePoint.CRRTKN); invalidValue(CodePoint.CRRTKN); byte[] part1 = new byte[l - 6]; for (int i = 0; i < part1.length; i++) time + leftBrace + session.connNum + rightBrace; if (this.trace) trace("******************************************drdaID is: " + session.drdaID); database.setDrdaID(session.drdaID);
break; default: invalidCodePoint(codePoint); checkLength(CodePoint.SECMEC, 2); securityMechanism = reader.readNetworkShort(); if (this.trace) trace("parseSECCHK - Security mechanism = " + securityMechanism); invalidValue(CodePoint.SECMEC); break; database.secTokenIn); } catch (SQLException se) { println2Log(database.dbName, session.drdaID, se.getMessage()); if (securityCheckCode == 0) trace("**decrypted userid is: "+database.userId); database.secTokenIn); } catch (SQLException se) { println2Log(database.dbName, session.drdaID, se.getMessage()); if (securityCheckCode == 0) trace("**decrypted password is: " + database.password);
badObjectLength(CodePoint.SECMGRNM); break; checkLength(CodePoint.SECMEC, 2); securityMechanism = reader.readNetworkShort(); if (this.trace) trace("parseACCSEC - Security mechanism = " + securityMechanism); trace("parseACCSEC - SECCHKCD_NOTSUPPORTED [1] - " + securityMechanism + " <> " + server.getSecurityMechanism() + "\n"); trace("parseACCSEC - SECCHKCD_NOTSUPPORTED [2]\n"); myPublicKey = decryptionManager.obtainPublicKey(); } catch (SQLException e) { println2Log(null, session.drdaID, e.getMessage()); String dbname = parseRDBNAM(); setRdbName(dbname); break; default: invalidCodePoint(codePoint); missingCodePoint(CodePoint.SECMEC); setRdbName(Attribute.GFXD_DBNAME);
setStmtOrDbByteOrder(false, drdaStmt, parseTYPDEFNAM()); break; parseTYPDEFOVR(drdaStmt); break; sqlStmt = parseEncodedString(); if (sqlStmt != null) if (canIgnoreStmt(sqlStmt)) { trace("sqlStmt = " + sqlStmt); invalidCodePoint(codePoint); missingCodePoint(CodePoint.SQLSTT);
parseEXCSAT2(); return; appRequester.extnam = reader.readString(); if (this.trace) trace("extName = " + appRequester.extnam); if (appRequester.extnam.length() > CodePoint.MAX_NAME) tooBig(CodePoint.EXTNAM); break; parseMGRLVLLS(1); break; badObjectLength(CodePoint.SPVNAM); break; appRequester.srvnam = reader.readString(); if (this.trace) trace("serverName = " + appRequester.srvnam); if (appRequester.srvnam.length() > CodePoint.MAX_NAME) tooBig(CodePoint.SRVNAM); break; appRequester.srvrlslv = reader.readString(); if (this.trace) trace("serverlslv = " + appRequester.srvrlslv); if (appRequester.srvrlslv.length() > CodePoint.MAX_NAME) tooBig(CodePoint.SRVRLSLV); break;
trace(se.getMessage()); println2Log(database.dbName, session.drdaID, se.getMessage()); if (isAuthenticationException(databaseAccessException)) { println2Log(database.dbName, session.drdaID, "Driver not loaded" + e.getMessage()); try { agentError("Driver not loaded"); server.startNetworkServer(); } catch (Exception re) { println2Log(database.dbName, session.drdaID, "Failed attempt to reload driver " +re.getMessage() ); if (getLogConnections()) println2Log(database.dbName, session.drdaID, "Pivotal GemFireXD Server connected to database " + database.dbName);
writeSQLCAGRP(nullSQLState, sqlcode, updateCount, rowCount); return; trace("handle SQLException here"); trace("reason is: "+e.getMessage()); trace("SQLState is: "+e.getSQLState()); trace("vendorCode is: "+e.getErrorCode()); trace("nextException is: "+e.getNextException()); server.consoleExceptionPrint(e); trace("wrapping SQLException into SQLCARD..."); writeSQLCAXGRP(updateCount, rowCount, buildSqlerrmc(e), e.getNextException());
trace("rdbnam = " + rdbnam + "; actual = " + Attribute.GFXD_DBNAME); if (!Attribute.GFXD_DBNAME.equals(rdbnam.toString())) { rdbnamMismatch(CodePoint.PKGNAMCSN); trace("rdbcolid = " + rdbcolid); trace("pkgid = " + pkgid); trace("pkgcnstkn = " + pkgcnstkn); trace("pkgsn = " + pkgsn); badObjectLength(CodePoint.RDBNAM); reader.readString(rdbnam, length, true); if (this.trace) trace("rdbnam = " + rdbnam + "; actual = " + Attribute.GFXD_DBNAME); if (!Attribute.GFXD_DBNAME.equals(rdbnam.toString())) { rdbnamMismatch(CodePoint.PKGNAMCSN); reader.readString(rdbcolid, length, true); if (this.trace) trace("rdbcolid = " + rdbcolid); badObjectLength(CodePoint.PKGID);
rdbNotFound(null); badObjectLength(CodePoint.RDBNAM); name = reader.convertBytes(rdbName); trace("RdbName = " + name + "; actual = " + Attribute.GFXD_DBNAME); return Attribute.GFXD_DBNAME;
/** * Write RDBNAM * * @param rdbnam database name * @exception DRDAProtocolException */ protected void writeRDBNAM(String rdbnam) throws DRDAProtocolException { int len = rdbnam.length(); if (len < CodePoint.RDBNAM_LEN) len = CodePoint.RDBNAM_LEN; writer.writeScalarHeader(CodePoint.RDBNAM, len); try { writer.writeScalarPaddedBytes(rdbnam.getBytes(server.DEFAULT_ENCODING), len, server.SPACE_CHAR); } catch (UnsupportedEncodingException e) { agentError("Unsupported coding exception for server encoding " + server.DEFAULT_ENCODING); } } /***************************************************************************
sqlerrmc = buildTokenizedSqlerrmc(se); sqlerrmc = buildPreformattedSqlerrmc(se);
thread = new DRDAConnThread(session, this, getTimeSlice(), getLogConnections()); threadList.add(thread); thread.start();
threadList.get(i)).buildRuntimeInfo("",locallangUtil) ; if (!sessionInfo.equals(""))