📄 statement.java
字号:
*/ boolean execute(String sql) throws SQLException; /** * Retrieves the current result as a <code>ResultSet</code> object. * This method should be called only once per result. * * @return the current result as a <code>ResultSet</code> object or * <code>null</code> if the result is an update count or there are no more results * @exception SQLException if a database access error occurs * @see #execute */ ResultSet getResultSet() throws SQLException; /** * Retrieves the current result as an update count; * if the result is a <code>ResultSet</code> object or there are no more results, -1 * is returned. This method should be called only once per result. * * @return the current result as an update count; -1 if the current result is a * <code>ResultSet</code> object or there are no more results * @exception SQLException if a database access error occurs * @see #execute */ int getUpdateCount() throws SQLException; /** * Moves to this <code>Statement</code> object's next result, returns * <code>true</code> if it is a <code>ResultSet</code> object, and * implicitly closes any current <code>ResultSet</code> * object(s) obtained with the method <code>getResultSet</code>. * * <P>There are no more results when the following is true: * <PRE> * // stmt is a Statement object * ((stmt.getMoreResults() == false) && (stmt.getUpdateCount() == -1)) * </PRE> * * @return <code>true</code> if the next result is a <code>ResultSet</code> * object; <code>false</code> if it is an update count or there are * no more results * @exception SQLException if a database access error occurs * @see #execute */ boolean getMoreResults() throws SQLException; //--------------------------JDBC 2.0----------------------------- /** * Gives the driver a hint as to the direction in which * rows will be processed in <code>ResultSet</code> * objects created using this <code>Statement</code> object. The * default value is <code>ResultSet.FETCH_FORWARD</code>. * <P> * Note that this method sets the default fetch direction for * result sets generated by this <code>Statement</code> object. * Each result set has its own methods for getting and setting * its own fetch direction. * * @param direction the initial direction for processing rows * @exception SQLException if a database access error occurs * or the given direction * is not one of <code>ResultSet.FETCH_FORWARD</code>, * <code>ResultSet.FETCH_REVERSE</code>, or <code>ResultSet.FETCH_UNKNOWN</code> * @since 1.2 * @see #getFetchDirection */ void setFetchDirection(int direction) throws SQLException; /** * Retrieves the direction for fetching rows from * database tables that is the default for result sets * generated from this <code>Statement</code> object. * If this <code>Statement</code> object has not set * a fetch direction by calling the method <code>setFetchDirection</code>, * the return value is implementation-specific. * * @return the default fetch direction for result sets generated * from this <code>Statement</code> object * @exception SQLException if a database access error occurs * @since 1.2 * @see #setFetchDirection */ int getFetchDirection() throws SQLException; /** * Gives 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 affects only result sets created using this * statement. 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 <= <code>rows</code> <= <code>this.getMaxRows()</code> * is not satisfied. * @since 1.2 * @see #getFetchSize */ void setFetchSize(int rows) throws SQLException; /** * Retrieves the number of result set rows that is the default * fetch size for <code>ResultSet</code> objects * generated from this <code>Statement</code> object. * If this <code>Statement</code> object has not set * a fetch size by calling the method <code>setFetchSize</code>, * the return value is implementation-specific. * * @return the default fetch size for result sets generated * from this <code>Statement</code> object * @exception SQLException if a database access error occurs * @since 1.2 * @see #setFetchSize */ int getFetchSize() throws SQLException; /** * Retrieves the result set concurrency for <code>ResultSet</code> objects * generated by this <code>Statement</code> object. * * @return either <code>ResultSet.CONCUR_READ_ONLY</code> or * <code>ResultSet.CONCUR_UPDATABLE</code> * @exception SQLException if a database access error occurs * @since 1.2 */ int getResultSetConcurrency() throws SQLException; /** * Retrieves the result set type for <code>ResultSet</code> objects * generated by this <code>Statement</code> object. * * @return one of <code>ResultSet.TYPE_FORWARD_ONLY</code>, * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> * @exception SQLException if a database access error occurs * @since 1.2 */ int getResultSetType() throws SQLException; /** * Adds the given SQL command to the current list of commmands for this * <code>Statement</code> object. The commands in this list can be * executed as a batch by calling the method <code>executeBatch</code>. * <P> * <B>NOTE:</B> This method is optional. * * @param sql typically this is a static SQL <code>INSERT</code> or * <code>UPDATE</code> statement * @exception SQLException if a database access error occurs, or the * driver does not support batch updates * @see #executeBatch * @since 1.2 */ void addBatch( String sql ) throws SQLException; /** * Empties this <code>Statement</code> object's current list of * SQL commands. * <P> * <B>NOTE:</B> This method is optional. * * @exception SQLException if a database access error occurs or the * driver does not support batch updates * @see #addBatch * @since 1.2 */ void clearBatch() throws SQLException; /** * Submits a batch of commands to the database for execution and * if all commands execute successfully, returns an array of update counts. * The <code>int</code> elements of the array that is returned are ordered * to correspond to the commands in the batch, which are ordered * according to the order in which they were added to the batch. * The elements in the array returned by the method <code>executeBatch</code> * may be one of the following: * <OL> * <LI>A number greater than or equal to zero -- indicates that the * command was processed successfully and is an update count giving the * number of rows in the database that were affected by the command's * execution * <LI>A value of <code>SUCCESS_NO_INFO</code> -- indicates that the command was * processed successfully but that the number of rows affected is * unknown * <P> * If one of the commands in a batch update fails to execute properly, * this method throws a <code>BatchUpdateException</code>, and a JDBC * driver may or may not continue to process the remaining commands in * the batch. However, the driver's behavior must be consistent with a * particular DBMS, either always continuing to process commands or never * continuing to process commands. If the driver continues processing * after a failure, the array returned by the method * <code>BatchUpdateException.getUpdateCounts</code> * will contain as many elements as there are commands in the batch, and * at least one of the elements will be the following: * <P> * <LI>A value of <code>EXECUTE_FAILED</code> -- indicates that the command failed * to execute successfully and occurs only if a driver continues to * process commands after a command fails * </OL> * <P> * A driver is not required to implement this method. * The possible implementations and return values have been modified in * the Java 2 SDK, Standard Edition, version 1.3 to * accommodate the option of continuing to proccess commands in a batch * update after a <code>BatchUpdateException</code> obejct has been thrown. * * @return an array of update counts containing one element for each * command in the batch. The elements of the array are ordered according * to the order in which commands were added to the batch. * @exception SQLException if a database access error occurs or the * driver does not support batch statements. Throws {@link BatchUpdateException} * (a subclass of <code>SQLException</code>) if one of the commands sent to the * database fails to execute properly or attempts to return a result set. * @since 1.3 */ int[] executeBatch() throws SQLException; /** * Retrieves the <code>Connection</code> object * that produced this <code>Statement</code> object. * @return the connection that produced this statement * @exception SQLException if a database access error occurs * @since 1.2 */ Connection getConnection() throws SQLException; //--------------------------JDBC 3.0----------------------------- /** * The constant indicating that the current <code>ResultSet</code> object * should be closed when calling <code>getMoreResults</code>. * * @since 1.4 */ int CLOSE_CURRENT_RESULT = 1; /** * The constant indicating that the current <code>ResultSet</code> object * should not be closed when calling <code>getMoreResults</code>. * * @since 1.4 */ int KEEP_CURRENT_RESULT = 2; /** * The constant indicating that all <code>ResultSet</code> objects that * have previously been kept open should be closed when calling * <code>getMoreResults</code>. * * @since 1.4 */ int CLOSE_ALL_RESULTS = 3; /** * The constant indicating that a batch statement executed successfully * but that no count of the number of rows it affected is available. * * @since 1.4 */ int SUCCESS_NO_INFO = -2; /** * The constant indicating that an error occured while executing a * batch statement.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -