📄 brokeredstatement.java
字号:
public final ResultSet getResultSet() throws SQLException { return wrapResultSet(getStatement().getResultSet()); } /** * getUpdateCount returns the current result as an update count; * if the result is a ResultSet or there are no more results -1 * is returned. It should only be called once per result. * * <P>The only way to tell for sure that the result is an update * count is to first test to see if it is a ResultSet. If it is * not a ResultSet it is either an update count or there are no * more results. * * @return the current result as an update count; -1 if it is a * ResultSet or there are no more results * @see #execute */ public final int getUpdateCount() throws SQLException { return getStatement().getUpdateCount(); } /** * getMoreResults moves to a Statement's next result. It returns true if * this result is a ResultSet. getMoreResults also implicitly * closes any current ResultSet obtained with getResultSet. * * There are no more results when (!getMoreResults() && * (getUpdateCount() == -1) * * @return true if the next result is a ResultSet; false if it is * an update count or there are no more results * @see #execute * @exception SQLException thrown on failure. */ public final boolean getMoreResults() throws SQLException { return getStatement().getMoreResults(); } /** * JDBC 2.0 * * Determine the result set type. * * @exception SQLException Feature not implemented for now. */ public final int getResultSetType() throws SQLException { return getStatement().getResultSetType(); } /** * JDBC 2.0 * * Give a hint as to the direction in which the rows in a result set * will be processed. The hint applies only to result sets created * using this Statement object. The default value is * ResultSet.FETCH_FORWARD. * * @param direction the initial direction for processing rows * @exception SQLException if a database-access error occurs or direction * is not one of ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, or * ResultSet.FETCH_UNKNOWN */ public final void setFetchDirection(int direction) throws SQLException { getStatement().setFetchDirection( direction); } /** * JDBC 2.0 * * Give the JDBC driver a hint as to the number of rows that should * be fetched from the database when more rows are needed. The number * of rows specified only affects result sets created using this * getStatement(). If the value specified is zero, then the hint is ignored. * The default value is zero. * * @param rows the number of rows to fetch * @exception SQLException if a database-access error occurs, or the * condition 0 <= rows <= this.getMaxRows() is not satisfied. */ public final void setFetchSize(int rows) throws SQLException { getStatement().setFetchSize( rows); } public final int getQueryTimeout() throws SQLException { return getStatement().getQueryTimeout(); } public final void setQueryTimeout(int seconds) throws SQLException { getStatement().setQueryTimeout( seconds); } /* ** JDBC 3.0 methods */ public final boolean execute(String sql, int autoGeneratedKeys) throws SQLException { return getStatement().execute( sql, autoGeneratedKeys); } public final boolean execute(String sql, int[] columnIndexes) throws SQLException { return getStatement().execute( sql, columnIndexes); } public final boolean execute(String sql, String[] columnNames) throws SQLException { return getStatement().execute( sql, columnNames); } public final int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { int retVal = getStatement().executeUpdate( sql, autoGeneratedKeys); return retVal; } public final int executeUpdate(String sql, int[] columnIndexes) throws SQLException { return getStatement().executeUpdate( sql, columnIndexes); } public final int executeUpdate(String sql, String[] columnNames) throws SQLException { return getStatement().executeUpdate( sql, columnNames); } /** * JDBC 3.0 * * Moves to this Statement obect's next result, deals with any current ResultSet * object(s) according to the instructions specified by the given flag, and * returns true if the next result is a ResultSet object * * @param current - one of the following Statement constants indicating what * should happen to current ResultSet objects obtained using the method * getResultSetCLOSE_CURRENT_RESULT, KEEP_CURRENT_RESULT, or CLOSE_ALL_RESULTS * @return true if the next result is a ResultSet; false if it is * an update count or there are no more results * @see #execute * @exception SQLException thrown on failure. */ public final boolean getMoreResults(int current) throws SQLException { return ((EngineStatement) getStatement()).getMoreResults( current); } /** * JDBC 3.0 * * Retrieves any auto-generated keys created as a result of executing this * Statement object. If this Statement object did not generate any keys, an empty * ResultSet object is returned. If this Statement is a non-insert statement, * an exception will be thrown. * * @return a ResultSet object containing the auto-generated key(s) generated by * the execution of this Statement object * @exception SQLException if a database access error occurs */ public final ResultSet getGeneratedKeys() throws SQLException { return wrapResultSet(getStatement().getGeneratedKeys()); } /** * Return the holdability of ResultSets created by this Statement. * If this Statement is active in a global transaction the * CLOSE_CURSORS_ON_COMMIT will be returned regardless of * the holdability it was created with. In a local transaction * the original create holdabilty will be returned. */ public final int getResultSetHoldability() throws SQLException { int holdability = ((EngineStatement) getStatement()).getResultSetHoldability(); // Holdability might be downgraded. return controlCheck().checkHoldCursors(holdability); } /* ** Control methods */ public Statement createDuplicateStatement(Connection conn, Statement oldStatement) throws SQLException { Statement newStatement; if (jdbcLevel == 2) newStatement = conn.createStatement(resultSetType, resultSetConcurrency); else newStatement = conn.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); setStatementState(oldStatement, newStatement); return newStatement; } void setStatementState(Statement oldStatement, Statement newStatement) throws SQLException { if (cursorName != null) newStatement.setCursorName(cursorName); if (escapeProcessing != null) newStatement.setEscapeProcessing(escapeProcessing.booleanValue()); newStatement.setFetchDirection(oldStatement.getFetchDirection()); newStatement.setFetchSize(oldStatement.getFetchSize()); newStatement.setMaxFieldSize(oldStatement.getMaxFieldSize()); newStatement.setMaxRows(oldStatement.getMaxRows()); newStatement.setQueryTimeout(oldStatement.getQueryTimeout()); } public Statement getStatement() throws SQLException { return control.getRealStatement(); } /** * Provide the control access to every ResultSet we return. * If required the control can wrap the ResultSet, but * it (the control) must ensure a underlying ResultSet is * only wrapped once, if say java.sql.Statement.getResultSet * is returned twice. * * @param rs ResultSet being returned, can be null. */ final ResultSet wrapResultSet(ResultSet rs) { return control.wrapResultSet(this, rs); } /** Get the BrokeredStatementControl in order to perform a check. Obtained indirectly to ensure that the correct exception is thrown if the Statement has been closed. */ final BrokeredStatementControl controlCheck() throws SQLException { // simplest method that will throw an exception if the Statement is closed getStatement().getConnection(); return control; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -