/** * Directly executes all of the sql statements in the list represented by the sql argument string. * * @param sql a sql string * @return the result of the last sql statement in the list */ synchronized Result sqlExecuteDirect(String sql) { try { if (Trace.DOASSERT) { Trace.doAssert(!isNestedTransaction); } Trace.check(!isClosed, Trace.ACCESS_IS_DENIED, "Session is closed"); synchronized (dDatabase) { Trace.check(!dDatabase.isShutdown(), Trace.DATABASE_IS_SHUTDOWN); return dbCommandInterpreter.execute(sql); } } catch (Throwable t) { return new Result(t, null); } }
Result sqlExecuteDirectNoPreChecks(String sql) { return dbCommandInterpreter.execute(sql); }
private Result sqlExecuteBatchDirect(Result cmd) { Record record; Result in; Result out; Result err; int[] updateCounts; int count; String sql; count = 0; updateCounts = new int[cmd.getSize()]; record = cmd.rRoot; out = new Result(ResultConstants.SQLEXECUTE, updateCounts, 0); err = new Result(ResultConstants.ERROR); while (record != null) { sql = (String) record.data[0]; in = err; try { in = dbCommandInterpreter.execute(sql); } catch (Throwable t) { // if (t instanceof OutOfMemoryError) { // System.gc(); // } // "in" alread equals "err" // maybe test for OOME and do a gc() ? // t.printStackTrace(); } // On the client side, iterate over the colType vals and throw // a BatchUpdateException if a batch status value of // ResultConstants.EXECUTE_FAILED is encountered switch (in.iMode) { case ResultConstants.UPDATECOUNT: { updateCounts[count++] = in.iUpdateCount; break; } case ResultConstants.DATA: { // FIXME: we don't have what it takes yet // to differentiate between things like // stored procedure calls to methods with // void return type and select statements with // a single row/column containg null updateCounts[count++] = ResultConstants.SUCCESS_NO_INFO; break; } case ResultConstants.ERROR: default: { updateCounts[count++] = ResultConstants.EXECUTE_FAILED; break; } } record = record.next; } return out; }