/** * Get a new DRDA statement and store it in the stmtTable if stortStmt is * true. If possible recycle an existing statement. When the server gets a * new statement with a previously used pkgnamcsn, it means that * client-side statement associated with this pkgnamcsn has been closed. In * this case, server can re-use the DRDAStatement by doing the following: * 1) Retrieve the old DRDAStatement associated with this pkgnamcsn and * close it. * 2) Reset the DRDAStatement state for re-use. * * @param pkgnamcsn Package name and section * @return DRDAStatement */ protected DRDAStatement newDRDAStatement(Pkgnamcsn pkgnamcsn) throws SQLException { DRDAStatement stmt = getDRDAStatement(pkgnamcsn); if (stmt != null) { stmt.close(); stmt.reset(); } else { stmt = new DRDAStatement(this); stmt.setPkgnamcsn(pkgnamcsn); storeStatement(stmt); } return stmt; }
private byte executeBatch(final DRDAStatement stmt, final boolean doAdd) throws SQLException { if (doAdd) { stmt.addBatch(); } if (reader.getCurrChainState() != DssConstants.DSS_NOCHAIN) { return CodePoint.OUTEXP_BATCH_OUTPUT; } else { // end of batch final boolean result = stmt.execute(true); return (byte)(CodePoint.OUTEXP_BATCH_OUTPUT | (result ? CodePoint.TRUE : CodePoint.FALSE)); } }
setStatus("EXECUTING BATCH"); this.statementAccessFrequency++; this.executionBeginTime = System.currentTimeMillis(); setStatus("EXECUTING PREPAREDSTATEMENT"); this.statementAccessFrequency++; this.executionBeginTime = System.currentTimeMillis(); hasResultSet = this.ps.execute(); if (!hasResultSet) { setStatus("CHECKING BUCKET HOSTED"); checkBucketsStillHosted(); setStatus("DONE"); this.batchResult = null; s = this.pstmt; setStatus("EXECUTING STATEMENT"); this.executionBeginTime = System.currentTimeMillis(); hasResultSet = this.pstmt.execute(this.sqlText); if (!hasResultSet) { setStatus("DONE"); setStatus("IOException " + ioe.getMessage()); throw TransactionResourceImpl.wrapInSQLException(ioe); } finally { addResultSet(rs, rs.getHoldability()); addResultSet(rs, withHoldCursor);
stmt.setStatus("SENDING CNTQRY RESULTS"); writeQRYDTA(stmt); stmt.checkBucketsStillHosted(); if (stmt.rsIsClosed()) checkWarning(null, null, stmt.getResultSet(), 0, false, sendWarningsOnCNTQRY); writePBSD(); checkWarning(null, database.getDefaultStatement().getStatement(), null, updateCount, true, true); writePBSD(); if (currStmt.isPrepared()) { if (currStmt.needStatementUUID()) { try { writeSQLSTMTID(currStmt.getStatementUUID()); } finally { currStmt.setSendStatementUUID(false); ps = stmt.getUnderlyingStatement(); stmt.setSchema(this.pendingSetSchema); this.pendingSetSchema = null; stmt.rsSuspend();
PreparedStatement ps = stmt.getPreparedStatement(); int codePoint; ParameterMetaData pmeta = null; stmt.clearDrdaParams(); if (this.trace) trace("drdaLength is: "+drdaLength); stmt.addDrdaParam(t, drdaLength); numVars = stmt.getDrdaParamCount(); if (this.trace) trace("numVars = " + numVars); try { cs = (CallableStatement) stmt.prepare(prepareString); stmt.registerAllOutParams(); } catch (SQLException se) { if (! stmt.outputExpected || trace ("$$ prepareCall is: "+prepareString); try { cs = (CallableStatement) stmt.prepare(prepareString); } catch (SQLException se2) pmeta = stmt.getParameterMetaData(); if ((stmt.getParamDRDAType(i+1) & 0x1) == 0x1) // nullable
throws DRDAProtocolException, SQLException PreparedStatement ps = stmt.getPreparedStatement(); final int drdaType = ((stmt.getParamDRDAType(i+1) | 0x01) & 0xff); final int paramLenNumBytes = stmt.getParamLen(i+1); if (stmt.isOutputParam(i+1)) cs.registerOutParameter(i+1, stmt.getOutputParamType(i+1)); if (length != 0) //can be -1 for CLI if "data at exec" mode, see clifp/exec test stmt.addExtPosition(i);
ConsistencyToken newRsPkgcnstkn = calculateResultSetPkgcnstkn(rsNum); newDrdaRs.setPkgcnstkn(newRsPkgcnstkn); newDrdaRs.withHoldCursor = holdValue; setRsDefaultOptions(newDrdaRs); newDrdaRs.suspend(); numResultSets++;
if (stmt.wasExplicitlyClosed()) stmt.CLSQRY();
private void initializeDefaultStatement() { this.defaultStatement = new DRDAStatement(this); }
stmt.addExtDtaObject(val, index);
stmt.setStatus("SENDING CNTQRY RESULTS"); writeQRYDTA(stmt); stmt.checkBucketsStillHosted(); if (stmt.rsIsClosed()) checkWarning(null, null, stmt.getResultSet(), 0, false, sendWarningsOnCNTQRY); writePBSD(); checkWarning(null, database.getDefaultStatement().getStatement(), null, updateCount, true, true); writePBSD(); if (currStmt.isPrepared()) { if (currStmt.needStatementUUID()) { try { writeSQLSTMTID(currStmt.getStatementUUID()); } finally { currStmt.setSendStatementUUID(false); ps = stmt.getUnderlyingStatement(); stmt.setSchema(this.pendingSetSchema); this.pendingSetSchema = null; stmt.rsSuspend();
PreparedStatement ps = stmt.getPreparedStatement(); int codePoint; ParameterMetaData pmeta = null; stmt.clearDrdaParams(); if (this.trace) trace("drdaLength is: "+drdaLength); stmt.addDrdaParam(t, drdaLength); numVars = stmt.getDrdaParamCount(); if (this.trace) trace("numVars = " + numVars); try { cs = (CallableStatement) stmt.prepare(prepareString); stmt.registerAllOutParams(); } catch (SQLException se) { if (! stmt.outputExpected || trace ("$$ prepareCall is: "+prepareString); try { cs = (CallableStatement) stmt.prepare(prepareString); } catch (SQLException se2) pmeta = stmt.getParameterMetaData(); if ((stmt.getParamDRDAType(i+1) & 0x1) == 0x1) // nullable
throws DRDAProtocolException, SQLException PreparedStatement ps = stmt.getPreparedStatement(); final int drdaType = ((stmt.getParamDRDAType(i+1) | 0x01) & 0xff); final int paramLenNumBytes = stmt.getParamLen(i+1); if (stmt.isOutputParam(i+1)) cs.registerOutParameter(i+1, stmt.getOutputParamType(i+1)); if (length != 0) //can be -1 for CLI if "data at exec" mode, see clifp/exec test stmt.addExtPosition(i);
ConsistencyToken newRsPkgcnstkn = calculateResultSetPkgcnstkn(rsNum); newDrdaRs.setPkgcnstkn(newRsPkgcnstkn); newDrdaRs.withHoldCursor = holdValue; setRsDefaultOptions(newDrdaRs); newDrdaRs.suspend(); numResultSets++;
if (stmt.wasExplicitlyClosed()) stmt.CLSQRY();
private void initializeDefaultStatement() { this.defaultStatement = new DRDAStatement(this); }
stmt.addExtDtaObject(val, index);
stmt.setStatus("SENDING CNTQRY RESULTS"); writeQRYDTA(stmt); stmt.checkBucketsStillHosted(); if (stmt.rsIsClosed()) checkWarning(null, null, stmt.getResultSet(), 0, false, sendWarningsOnCNTQRY); writePBSD(); checkWarning(null, database.getDefaultStatement().getStatement(), null, updateCount, true, true); writePBSD(); if (currStmt.isPrepared()) { if (currStmt.needStatementUUID()) { try { writeSQLSTMTID(currStmt.getStatementUUID()); } finally { currStmt.setSendStatementUUID(false); ps = stmt.getUnderlyingStatement(); stmt.setSchema(this.pendingSetSchema); this.pendingSetSchema = null; stmt.rsSuspend();
PreparedStatement ps = stmt.getPreparedStatement(); int codePoint; ParameterMetaData pmeta = null; stmt.clearDrdaParams(); if (this.trace) trace("drdaLength is: "+drdaLength); stmt.addDrdaParam(t, drdaLength); numVars = stmt.getDrdaParamCount(); if (this.trace) trace("numVars = " + numVars); try { cs = (CallableStatement) stmt.prepare(prepareString); stmt.registerAllOutParams(); } catch (SQLException se) { if (! stmt.outputExpected || trace ("$$ prepareCall is: "+prepareString); try { cs = (CallableStatement) stmt.prepare(prepareString); } catch (SQLException se2) pmeta = stmt.getParameterMetaData(); if ((stmt.getParamDRDAType(i+1) & 0x1) == 0x1) // nullable
throws DRDAProtocolException, SQLException PreparedStatement ps = stmt.getPreparedStatement(); final int drdaType = ((stmt.getParamDRDAType(i+1) | 0x01) & 0xff); final int paramLenNumBytes = stmt.getParamLen(i+1); if (stmt.isOutputParam(i+1)) cs.registerOutParameter(i+1, stmt.getOutputParamType(i+1)); if (length != 0) //can be -1 for CLI if "data at exec" mode, see clifp/exec test stmt.addExtPosition(i);