📄 statement.java
字号:
//----------------------- Multiple Results -------------------------- public boolean execute(String sql) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "execute", sql); } boolean b = executeX(sql); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "execute", b); } return b; } } boolean executeX(String sql) throws SqlException { flowExecute(executeMethod__, sql); return resultSet_ != null; } public java.sql.ResultSet getResultSet() throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getResultSet"); } checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc) if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getResultSet", resultSet_); } return resultSet_; } } public int getUpdateCount() throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getUpdateCount"); } checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc) if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getUpdateCount", updateCount_); } return updateCount_; } } public boolean getMoreResults() throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getMoreResults"); } boolean resultIsResultSet = getMoreResultsX(CLOSE_ALL_RESULTS); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getMoreResults", resultIsResultSet); } return resultIsResultSet; } } //--------------------------JDBC 2.0----------------------------- public void setFetchDirection(int direction) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setFetchDirection", direction); } checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc) switch (direction) { case java.sql.ResultSet.FETCH_FORWARD: case java.sql.ResultSet.FETCH_REVERSE: case java.sql.ResultSet.FETCH_UNKNOWN: fetchDirection_ = direction; break; default: throw new SqlException(agent_.logWriter_, "Invalid fetch direction " + direction); } } } public int getFetchDirection() throws SqlException { checkForClosedStatement(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getFetchDirection", fetchDirection_); } return fetchDirection_; } public void setFetchSize(int rows) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "setFetchSize", rows); } checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc) if (rows < 0 || (maxRows_ != 0 && rows > maxRows_)) { throw new SqlException(agent_.logWriter_, "Invalid fetch size " + rows); } fetchSize_ = rows; } } public int getFetchSize() throws SqlException { checkForClosedStatement(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getFetchSize", fetchSize_); } return fetchSize_; } public int getResultSetConcurrency() throws SqlException { checkForClosedStatement(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getResultSetConcurrency", resultSetConcurrency_); } return resultSetConcurrency_; } public int getResultSetType() throws SqlException { checkForClosedStatement(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getResultSetType", resultSetType_); } return resultSetType_; } public void addBatch(String sql) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "addBatch", sql); } checkForClosedStatement(); sql = connection_.nativeSQLX(sql); batch_.add(sql); } } public void clearBatch() throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "clearBatch"); } checkForClosedStatement(); batch_.clear(); } } public int[] executeBatch() throws SqlException, BatchUpdateException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeBatch"); } int[] updateCounts = executeBatchX(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "executeBatch", updateCounts); } return updateCounts; } } private int[] executeBatchX() throws SqlException, BatchUpdateException { checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc) clearWarningsX(); // Per jdbc spec 0.7, and getWarnings() javadoc resultSetList_ = null; // Initialize all the updateCounts to indicate failure // This is done to account for "chain-breaking" errors where we cannot // read any more replies int[] updateCounts = new int[batch_.size()]; for (int i = 0; i < batch_.size(); i++) { updateCounts[i] = -3; } flowExecuteBatch(updateCounts); return updateCounts; } public java.sql.Connection getConnection() throws SqlException { checkForClosedStatement(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getConnection", connection_); } return connection_; } //--------------------------JDBC 3.0----------------------------- public boolean getMoreResults(int current) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getMoreResults", current); } boolean resultIsResultSet = getMoreResultsX(current); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getMoreResults", resultIsResultSet); } return resultIsResultSet; } } private boolean getMoreResultsX(int current) throws SqlException { checkForClosedStatement(); // Per jdbc spec (see java.sql.Statement.close() javadoc) boolean resultIsResultSet; updateCount_ = -1; if (resultSetList_ == null) { if (resultSet_ != null) { if (current != KEEP_CURRENT_RESULT) { resultSet_.closeX(); } resultSet_ = null; } resultIsResultSet = false; } else { if (numInvisibleRS_ == 0 && current == CLOSE_CURRENT_RESULT && resultSetList_[indexOfCurrentResultSet_] != null) { resultSetList_[indexOfCurrentResultSet_].closeX(); } resultIsResultSet = indexOfCurrentResultSet_ + 1 < resultSetList_.length; } if ((current == CLOSE_ALL_RESULTS) && (numInvisibleRS_ == 0)) { int numberOfResultSetsToClose = (resultSetList_ == null) ? 0 : indexOfCurrentResultSet_ + 1; boolean willTickleServer = willTickleServer(numberOfResultSetsToClose, false); if (willTickleServer) { flowCloseRetrievedResultSets(); } else { flowCloseRetrievedResultSetsOutsideUOW(); } } if (resultIsResultSet) { resultSet_ = resultSetList_[++indexOfCurrentResultSet_]; } else { resultSet_ = null; } return resultIsResultSet; } public java.sql.ResultSet getGeneratedKeys() throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "getGeneratedKeys"); } checkForClosedStatement(); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "getGeneratedKeys", generatedKeysResultSet_); } return generatedKeysResultSet_; } public int executeUpdate(String sql, int autoGeneratedKeys) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeUpdate", sql, autoGeneratedKeys); } autoGeneratedKeys_ = autoGeneratedKeys; int updateValue = executeUpdateX(sql); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "executeUpdate", updateValue); } return updateValue; } } public int executeUpdate(String sql, int columnIndexes[]) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeUpdate", sql, columnIndexes); } checkForClosedStatement(); throw new SqlException(agent_.logWriter_, "Driver not capable"); } public int executeUpdate(String sql, String columnNames[]) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "executeUpdate", sql, columnNames); } generatedKeysColumnNames_ = columnNames; int updateValue = executeUpdateX(sql); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "executeUpdate", updateValue); } return updateValue; } } public boolean execute(String sql, int autoGeneratedKeys) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "execute", sql, autoGeneratedKeys); } autoGeneratedKeys_ = autoGeneratedKeys; boolean b = executeX(sql); if (agent_.loggingEnabled()) { agent_.logWriter_.traceExit(this, "execute", b); } return b; } } public boolean execute(String sql, int columnIndexes[]) throws SqlException { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "execute", sql, columnIndexes); } checkForClosedStatement(); throw new SqlException(agent_.logWriter_, "Driver not capable"); } public boolean execute(String sql, String columnNames[]) throws SqlException { synchronized (connection_) { if (agent_.loggingEnabled()) { agent_.logWriter_.traceEntry(this, "execute", sql, columnNames); } generatedKeysColumnNames_ = columnNames; boolean b = executeX(sql); if (agent_.loggingEnabled()) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -