Most visited

Recently visited

Added in API level 1

Statement

public interface Statement
implements Wrapper, AutoCloseable

java.sql.Statement
Known Indirect Subclasses


用于执行静态SQL语句并返回其生成的结果的对象。

默认情况下,每个Statement对象只能同时打开一个ResultSet对象。 因此,如果一个ResultSet对象的读数与另一个ResultSet的读数交错,则每个对象必须由不同的Statement对象生成。 如果存在打开的对象,则Statement接口中的所有执行方法隐式关闭该对象的当前ResultSet对象。

也可以看看:

Summary

Constants

int CLOSE_ALL_RESULTS

该常数表示在调用 getMoreResults时应关闭之前保持打开的所有 ResultSet对象。

int CLOSE_CURRENT_RESULT

该常数指示当调用 getMoreResults时应关闭当前的 ResultSet对象。

int EXECUTE_FAILED

该常数表示在执行批处理语句时发生错误。

int KEEP_CURRENT_RESULT

当调用 getMoreResults时,该常数指示当前的 ResultSet对象不应该关闭。

int NO_GENERATED_KEYS

表示生成的密钥不应用于检索的常量。

int RETURN_GENERATED_KEYS

表示生成的密钥应该可用于检索的常量。

int SUCCESS_NO_INFO

该常量表示批处理语句已成功执行,但不影响其受影响的行数。

Public methods

abstract void addBatch(String sql)

将给定的SQL命令添加到此 Statement对象的当前命令列表。

abstract void cancel()

如果DBMS和驱动程序都支持中止SQL语句,则取消此 Statement对象。

abstract void clearBatch()

清空这个 Statement对象的当前SQL命令列表。

abstract void clearWarnings()

清除此 Statement对象上报告的所有警告。

abstract void close()

立即释放此 Statement对象的数据库和JDBC资源,而不是在它自动关闭时等待它发生。

abstract boolean execute(String sql, int autoGeneratedKeys)

执行给定的SQL语句,该语句可能会返回多个结果,并向驱动程序发出通知,指出应该使任何自动生成的密钥可用于检索。

abstract boolean execute(String sql)

执行给定的SQL语句,该语句可能会返回多个结果。

abstract boolean execute(String sql, int[] columnIndexes)

执行给定的SQL语句,该语句可能会返回多个结果,并向驱动程序发出指示给定数组中指示的自动生成的键应该可用于检索的信号。

abstract boolean execute(String sql, String[] columnNames)

执行给定的SQL语句,该语句可能会返回多个结果,并向驱动程序发出指示给定数组中指示的自动生成的键应该可用于检索的信号。

abstract int[] executeBatch()

向数据库提交一批命令以执行,如果所有命令都成功执行,则返回一组更新计数。

abstract ResultSet executeQuery(String sql)

执行给定的SQL语句,该语句返回一个 ResultSet对象。

abstract int executeUpdate(String sql)

执行给定的SQL语句,这可能是 INSERTUPDATE ,或 DELETE声明,或者不返回任何内容,如SQL DDL语句的SQL语句。

abstract int executeUpdate(String sql, String[] columnNames)

执行给定的SQL语句并向驱动程序发出指示给定数组中指示的自动生成的键应该可用于检索的信号。

abstract int executeUpdate(String sql, int[] columnIndexes)

执行给定的SQL语句并向驱动程序发出指示给定数组中指示的自动生成的键应该可用于检索的信号。

abstract int executeUpdate(String sql, int autoGeneratedKeys)

执行给定的SQL语句并通过给定的标志向驱动程序发出有关是否应该使该 Statement对象产生的自动生成的密钥可用于检索的信号。

abstract Connection getConnection()

检索 Connection生成此对象 Statement对象。

abstract int getFetchDirection()

检索从数据库表中提取行的方向,这是从此 Statement对象生成的结果集的默认值。

abstract int getFetchSize()

检索结果集合的行数是默认为获取大小 ResultSet从该生成的对象 Statement对象。

abstract ResultSet getGeneratedKeys()

检索作为执行此 Statement对象的结果而创建的所有自动生成的密钥。

abstract int getMaxFieldSize()

检索由此 ResultSet对象生成的 Statement对象中可以返回字符和二进制列值的最大字节数。

abstract int getMaxRows()

检索 ResultSet对象生成的 Statement对象可以包含的最大行数。

abstract boolean getMoreResults(int current)

移动到此 Statement对象的下一个结果,与任何电流 ResultSet根据由给定的标志指定的指令对象(一个或多个),并且返回 true如果下一个结果是 ResultSet对象。

abstract boolean getMoreResults()

移动到 Statement对象的下一个结果,如果它是 ResultSet对象,则返回 true ,并隐式关闭使用方法 getResultSet获取的所有当前 ResultSet对象。

abstract int getQueryTimeout()

检索驱动程序等待执行 Statement对象的 Statement

abstract ResultSet getResultSet()

ResultSet对象的形式检索当前结果。

abstract int getResultSetConcurrency()

检索由此 ResultSet对象生成的 Statement对象的结果集并发性。

abstract int getResultSetHoldability()

检索由此 ResultSet对象生成的 Statement对象的结果集可保存性。

abstract int getResultSetType()

检索由此 ResultSet对象生成的 Statement对象的结果集类型。

abstract int getUpdateCount()

以更新计数检索当前结果; 如果结果是ResultSet对象或没有更多结果,则返回-1。

abstract SQLWarning getWarnings()

检索此 Statement对象通过调用报告的第一个警告。

abstract boolean isClosed()

检索此 Statement对象是否已关闭。

abstract boolean isPoolable()

返回一个值,指示 Statement是否可以 Statement

abstract void setCursorName(String name)

将SQL游标名称设置为给定的 String ,随后的 Statement对象将使用 execute方法 execute

abstract void setEscapeProcessing(boolean enable)

设置退出处理的开启或关闭。

abstract void setFetchDirection(int direction)

为驱动程序提供关于 ResultSet对象中使用此 Statement对象创建的行的处理方向的提示。

abstract void setFetchSize(int rows)

ResultSet对象需要更多行时,向JDBC驱动程序提示应该从数据库中提取的行 Statement

abstract void setMaxFieldSize(int max)

设置此 ResultSet对象生成的 Statement对象中可以返回字符和二进制列值的最大字节数限制。

abstract void setMaxRows(int max)

设置由此 ResultSet对象生成的任何 Statement对象可包含的给定数量的最大行数限制。

abstract void setPoolable(boolean poolable)

要求将 Statement合并或不合并。

abstract void setQueryTimeout(int seconds)

将驱动程序等待 Statement对象执行的秒数设置为给定秒数。

Inherited methods

From interface java.sql.Wrapper
From interface java.lang.AutoCloseable

Constants

CLOSE_ALL_RESULTS

Added in API level 1
int CLOSE_ALL_RESULTS

该常数指示在调用 getMoreResults时应关闭先前保持打开的所有 ResultSet对象。

常量值:3(0x00000003)

CLOSE_CURRENT_RESULT

Added in API level 1
int CLOSE_CURRENT_RESULT

当调用 getMoreResults时,该常数指示应关闭当前的 ResultSet对象。

常数值:1(0x00000001)

EXECUTE_FAILED

Added in API level 1
int EXECUTE_FAILED

该常数表示在执行批处理语句时发生错误。

常量值:-3(0xfffffffd)

KEEP_CURRENT_RESULT

Added in API level 1
int KEEP_CURRENT_RESULT

当调用 getMoreResults时,表示当前 ResultSet对象不应该关闭的 getMoreResults

常量值:2(0x00000002)

NO_GENERATED_KEYS

Added in API level 1
int NO_GENERATED_KEYS

表示生成的密钥不应用于检索的常量。

常量值:2(0x00000002)

RETURN_GENERATED_KEYS

Added in API level 1
int RETURN_GENERATED_KEYS

表示生成的密钥应该可用于检索的常量。

常数值:1(0x00000001)

SUCCESS_NO_INFO

Added in API level 1
int SUCCESS_NO_INFO

该常量表示批处理语句已成功执行,但不影响其受影响的行数。

常量值:-2(0xfffffffe)

Public methods

addBatch

Added in API level 1
void addBatch (String sql)

将给定的SQL命令添加到此Statement对象的当前命令列表中。 该列表中的命令可以通过调用方法executeBatch以批处理方式executeBatch

注意:此方法无法在 PreparedStatementCallableStatement

Parameters
sql String: typically this is a SQL INSERT or UPDATE statement
Throws
SQLException if a database access error occurs, this method is called on a closed Statement, the driver does not support batch updates, the method is called on a PreparedStatement or CallableStatement

也可以看看:

cancel

Added in API level 1
void cancel ()

如果DBMS和驱动程序都支持中止SQL语句,则取消此Statement对象。 这个方法可以被一个线程用来取消另一个线程正在执行的语句。

Throws
SQLException if a database access error occurs or this method is called on a closed Statement
SQLFeatureNotSupportedException if the JDBC driver does not support this method

clearBatch

Added in API level 1
void clearBatch ()

清空这个 Statement对象的当前SQL命令列表。

Throws
SQLException if a database access error occurs, this method is called on a closed Statement or the driver does not support batch updates

也可以看看:

clearWarnings

Added in API level 1
void clearWarnings ()

清除此Statement对象上报告的所有警告。 在调用此方法后,方法getWarnings将返回null直到报告此Statement对象的新警告。

Throws
SQLException if a database access error occurs or this method is called on a closed Statement

close

Added in API level 1
void close ()

立即释放此Statement对象的数据库和JDBC资源,而不是等待它自动关闭时发生。 一旦您完成了资源释放资源以避免捆绑数据库资源,通常是一种很好的做法。

调用已关闭的 Statement对象上的方法 close不起作用。

注:关闭 Statement对象时,其当前 ResultSet对象(如果存在)也会关闭。

Throws
SQLException if a database access error occurs

execute

Added in API level 1
boolean execute (String sql, 
                int autoGeneratedKeys)

执行给定的SQL语句,该语句可能会返回多个结果,并向驱动程序发出通知,指出应该使任何自动生成的密钥可用于检索。 如果SQL语句不是INSERT语句,或者SQL语句能够返回自动生成的键(这些语句的列表是特定于供应商的),驱动程序将忽略此信号。

在某些(不常见)情况下,单个SQL语句可能会返回多个结果集和/或更新计数。 通常情况下,你可以忽略它,除非你(1)执行一个你知道可能返回多个结果的存储过程,或者(2)你动态地执行一个未知的SQL字符串。

execute方法执行一条SQL语句并指示第一个结果的形式。 然后您必须使用方法getResultSetgetUpdateCount检索结果,并使用getMoreResults移至任何后续结果。

注意:此方法无法在 PreparedStatementCallableStatement

Parameters
sql String: any SQL statement
autoGeneratedKeys int: a constant indicating whether auto-generated keys should be made available for retrieval using the method getGeneratedKeys; one of the following constants: Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS
Returns
boolean true if the first result is a ResultSet object; false if it is an update count or there are no results
Throws
SQLException if a database access error occurs, this method is called on a closed Statement, the second parameter supplied to this method is not Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS, the method is called on a PreparedStatement or CallableStatement
SQLFeatureNotSupportedException if the JDBC driver does not support this method with a constant of Statement.RETURN_GENERATED_KEYS
SQLTimeoutException when the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement

也可以看看:

execute

Added in API level 1
boolean execute (String sql)

执行给定的SQL语句,该语句可能会返回多个结果。 在某些(不常见)情况下,单个SQL语句可能会返回多个结果集和/或更新计数。 通常情况下,你可以忽略它,除非你(1)执行一个你知道可能返回多个结果的存储过程,或者(2)你动态地执行一个未知的SQL字符串。

execute方法执行SQL语句并指示第一个结果的形式。 您必须使用方法getResultSetgetUpdateCount检索结果,并使用getMoreResults移至任何后续结果。

注意:此方法无法在 PreparedStatementCallableStatement

Parameters
sql String: any SQL statement
Returns
boolean true if the first result is a ResultSet object; false if it is an update count or there are no results
Throws
SQLException if a database access error occurs, this method is called on a closed Statement, the method is called on a PreparedStatement or CallableStatement
SQLTimeoutException when the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement

也可以看看:

execute

Added in API level 1
boolean execute (String sql, 
                int[] columnIndexes)

执行给定的SQL语句,该语句可能会返回多个结果,并向驱动程序发出指示给定数组中指示的自动生成的键应该可用于检索的信号。 此数组包含目标表中包含应该使其可用的自动生成的键的列索引。 如果SQL语句不是INSERT语句,或者SQL语句能够返回自动生成的键(这些语句的列表是特定于供应商的),驱动程序将忽略该数组。

在某些(不常见)情况下,单个SQL语句可能会返回多个结果集和/或更新计数。 通常情况下,你可以忽略它,除非你(1)执行一个你知道可能返回多个结果的存储过程,或者(2)你动态地执行一个未知的SQL字符串。

execute方法执行一条SQL语句并指示第一个结果的形式。 然后您必须使用方法getResultSetgetUpdateCount检索结果,并使用getMoreResults移至任何后续结果。

注意:此方法无法在 PreparedStatementCallableStatement

Parameters
sql String: any SQL statement
columnIndexes int: an array of the indexes of the columns in the inserted row that should be made available for retrieval by a call to the method getGeneratedKeys
Returns
boolean true if the first result is a ResultSet object; false if it is an update count or there are no results
Throws
SQLException if a database access error occurs, this method is called on a closed Statement, the elements in the int array passed to this method are not valid column indexes, the method is called on a PreparedStatement or CallableStatement
SQLFeatureNotSupportedException if the JDBC driver does not support this method
SQLTimeoutException when the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement

也可以看看:

execute

Added in API level 1
boolean execute (String sql, 
                String[] columnNames)

执行给定的SQL语句,该语句可能会返回多个结果,并向驱动程序发出指示给定数组中指示的自动生成的键应该可用于检索的信号。 此数组包含目标表中包含应该使其可用的自动生成的键的列的名称。 如果SQL语句不是INSERT语句,或者SQL语句能够返回自动生成的键(这些语句的列表是特定于供应商的),驱动程序将忽略数组。

在某些(不常见)情况下,单个SQL语句可能会返回多个结果集和/或更新计数。 通常情况下,你可以忽略它,除非你(1)执行一个你知道可能返回多个结果的存储过程,或者(2)你动态地执行一个未知的SQL字符串。

execute方法执行一条SQL语句并指示第一个结果的形式。 然后您必须使用方法getResultSetgetUpdateCount检索结果,并使用getMoreResults移至任何后续结果。

注意:此方法无法在 PreparedStatementCallableStatement

Parameters
sql String: any SQL statement
columnNames String: an array of the names of the columns in the inserted row that should be made available for retrieval by a call to the method getGeneratedKeys
Returns
boolean true if the next result is a ResultSet object; false if it is an update count or there are no more results
Throws
SQLException if a database access error occurs, this method is called on a closed Statement,the elements of the String array passed to this method are not valid column names, the method is called on a PreparedStatement or CallableStatement
SQLFeatureNotSupportedException if the JDBC driver does not support this method
SQLTimeoutException when the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement

也可以看看:

executeBatch

Added in API level 1
int[] executeBatch ()

向数据库提交一批命令以执行,如果所有命令都成功执行,则返回一组更新计数。 返回数组的int元素的顺序与批次中的命令相对应,这些命令按照它们添加到批次中的顺序排序。 由方法executeBatch返回的数组中的元素可能是以下之一:

  1. 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
  2. A value of SUCCESS_NO_INFO -- indicates that the command was processed successfully but that the number of rows affected is unknown

    如果批量更新中的某个命令无法正确执行,则此方法将引发BatchUpdateException ,并且JDBC驱动程序可能会或可能不会继续处理批处理中的其余命令。 但是,驱动程序的行为必须与特定的DBMS保持一致,要么始终继续处理命令,要么永远不会继续处理命令。 如果驱动程序在失败后继续处理,则方法BatchUpdateException.getUpdateCounts返回的数组将包含与批处理中的命令一样多的元素,并且至少有一个元素为以下内容:

  3. A value of EXECUTE_FAILED -- indicates that the command failed to execute successfully and occurs only if a driver continues to process commands after a command fails

在Java 2 SDK Standard Edition 1.3版中修改了可能的实现和返回值,以适应在抛出 BatchUpdateException对象后继续处理批量更新中的命令的选项。

Returns
int[] 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.
Throws
SQLException if a database access error occurs, this method is called on a closed Statement or the driver does not support batch statements. Throws BatchUpdateException (a subclass of SQLException) if one of the commands sent to the database fails to execute properly or attempts to return a result set.
SQLTimeoutException when the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement

也可以看看:

executeQuery

Added in API level 1
ResultSet executeQuery (String sql)

执行给定的SQL语句,该语句返回一个 ResultSet对象。

注意:此方法无法在 PreparedStatementCallableStatement

Parameters
sql String: an SQL statement to be sent to the database, typically a static SQL SELECT statement
Returns
ResultSet a ResultSet object that contains the data produced by the given query; never null
Throws
SQLException if a database access error occurs, this method is called on a closed Statement, the given SQL statement produces anything other than a single ResultSet object, the method is called on a PreparedStatement or CallableStatement
SQLTimeoutException when the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement

executeUpdate

Added in API level 1
int executeUpdate (String sql)

执行给定的SQL语句,这可能是 INSERTUPDATE ,或 DELETE声明,或者不返回任何内容,如SQL DDL语句的SQL语句。

注意:此方法无法在 PreparedStatementCallableStatement

Parameters
sql String: an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
Returns
int either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
Throws
SQLException if a database access error occurs, this method is called on a closed Statement, the given SQL statement produces a ResultSet object, the method is called on a PreparedStatement or CallableStatement
SQLTimeoutException when the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement

executeUpdate

Added in API level 1
int executeUpdate (String sql, 
                String[] columnNames)

执行给定的SQL语句并向驱动程序发出指示给定数组中指示的自动生成的键应该可用于检索的信号。 此数组包含目标表中包含应该使其可用的自动生成的键的列的名称。 如果SQL语句不是INSERT语句,或者SQL语句能够返回自动生成的键(这些语句的列表是特定于供应商的),驱动程序将忽略该数组。

注意:不能在 PreparedStatementCallableStatement上调用此方法。

Parameters
sql String: an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
columnNames String: an array of the names of the columns that should be returned from the inserted row
Returns
int either the row count for INSERT, UPDATE, or DELETE statements, or 0 for SQL statements that return nothing
Throws
SQLException if a database access error occurs, this method is called on a closed Statement, the SQL statement returns a ResultSet object, the second argument supplied to this method is not a String array whose elements are valid column names, the method is called on a PreparedStatement or CallableStatement
SQLFeatureNotSupportedException if the JDBC driver does not support this method
SQLTimeoutException when the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement

executeUpdate

Added in API level 1
int executeUpdate (String sql, 
                int[] columnIndexes)

执行给定的SQL语句并向驱动程序发出指示给定数组中指示的自动生成的键应该可用于检索的信号。 此数组包含目标表中包含应该使其可用的自动生成的键的列索引。 如果SQL语句不是INSERT语句,或者SQL语句能够返回自动生成的键(这些语句的列表是特定于供应商的),驱动程序将忽略该数组。

注意:此方法无法在 PreparedStatementCallableStatement

Parameters
sql String: an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
columnIndexes int: an array of column indexes indicating the columns that should be returned from the inserted row
Returns
int either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
Throws
SQLException if a database access error occurs, this method is called on a closed Statement, the SQL statement returns a ResultSet object,the second argument supplied to this method is not an int array whose elements are valid column indexes, the method is called on a PreparedStatement or CallableStatement
SQLFeatureNotSupportedException if the JDBC driver does not support this method
SQLTimeoutException when the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement

executeUpdate

Added in API level 1
int executeUpdate (String sql, 
                int autoGeneratedKeys)

执行给定的SQL语句并用给定的标志向驱动程序发出有关是否应该使该Statement对象产生的自动生成的密钥可用于检索的信号。 如果SQL语句不是INSERT语句,或者SQL语句能够返回自动生成的键(这些语句的列表是特定于供应商的),驱动程序将忽略此标志。

注意:此方法无法在 PreparedStatementCallableStatement

Parameters
sql String: an SQL Data Manipulation Language (DML) statement, such as INSERT, UPDATE or DELETE; or an SQL statement that returns nothing, such as a DDL statement.
autoGeneratedKeys int: a flag indicating whether auto-generated keys should be made available for retrieval; one of the following constants: Statement.RETURN_GENERATED_KEYS Statement.NO_GENERATED_KEYS
Returns
int either (1) the row count for SQL Data Manipulation Language (DML) statements or (2) 0 for SQL statements that return nothing
Throws
SQLException if a database access error occurs, this method is called on a closed Statement, the given SQL statement returns a ResultSet object, the given constant is not one of those allowed, the method is called on a PreparedStatement or CallableStatement
SQLFeatureNotSupportedException if the JDBC driver does not support this method with a constant of Statement.RETURN_GENERATED_KEYS
SQLTimeoutException when the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement

getConnection

Added in API level 1
Connection getConnection ()

检索 Connection生成此对象 Statement对象。

Returns
Connection the connection that produced this statement
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

getFetchDirection

Added in API level 1
int getFetchDirection ()

检索从数据库表中提取行的方向,这是从此Statement对象生成的结果集的默认值。 如果此Statement对象没有通过调用方法setFetchDirection设置获取方向,则返回值是特定于实现的。

Returns
int the default fetch direction for result sets generated from this Statement object
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

也可以看看:

getFetchSize

Added in API level 1
int getFetchSize ()

检索结果集合的行数是默认为获取大小ResultSet从该生成的对象Statement对象。 如果此Statement对象没有通过调用方法setFetchSize设置获取大小,则返回值是特定于实现的。

Returns
int the default fetch size for result sets generated from this Statement object
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

也可以看看:

getGeneratedKeys

Added in API level 1
ResultSet getGeneratedKeys ()

检索由于执行此Statement对象而创建的所有自动生成的密钥。 如果这个Statement对象没有生成任何键,则返回一个空的ResultSet对象。

注意:如果未指定代表自动生成密钥的列,则JDBC驱动程序实现将确定最能代表自动生成密钥的列。

Returns
ResultSet a ResultSet object containing the auto-generated key(s) generated by the execution of this Statement object
Throws
SQLException if a database access error occurs or this method is called on a closed Statement
SQLFeatureNotSupportedException if the JDBC driver does not support this method

getMaxFieldSize

Added in API level 1
int getMaxFieldSize ()

检索由此ResultSet对象生成的Statement对象中可以返回字符和二进制列值的最大字节数。 此限制仅适用于BINARYVARBINARYLONGVARBINARYCHARVARCHARNCHARNVARCHARLONGNVARCHARLONGVARCHAR列。 如果超出限制,则会过多丢弃超量数据。

Returns
int the current column size limit for columns storing character and binary values; zero means there is no limit
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

也可以看看:

getMaxRows

Added in API level 1
int getMaxRows ()

检索ResultSet对象生成的Statement对象可以包含的最大行数。 如果超出此限制,多余的行将被无声地丢弃。

Returns
int the current maximum number of rows for a ResultSet object produced by this Statement object; zero means there is no limit
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

也可以看看:

getMoreResults

Added in API level 1
boolean getMoreResults (int current)

移动到此 Statement对象的下一个结果,与任何电流 ResultSet根据由给定的标志指定的指令对象(一个或多个),并且返回 true如果下一个结果是 ResultSet对象。

当以下情况属实时,没有更多结果:

     // stmt is a Statement object
     ((stmt.getMoreResults(current) == false) && (stmt.getUpdateCount() == -1))
 

Parameters
current int: one of the following Statement constants indicating what should happen to current ResultSet objects obtained using the method getResultSet: Statement.CLOSE_CURRENT_RESULT, Statement.KEEP_CURRENT_RESULT, or Statement.CLOSE_ALL_RESULTS
Returns
boolean true if the next result is a ResultSet object; false if it is an update count or there are no more results
Throws
SQLException if a database access error occurs, this method is called on a closed Statement or the argument supplied is not one of the following: Statement.CLOSE_CURRENT_RESULT, Statement.KEEP_CURRENT_RESULT or Statement.CLOSE_ALL_RESULTS
SQLFeatureNotSupportedException if DatabaseMetaData.supportsMultipleOpenResults returns false and either Statement.KEEP_CURRENT_RESULT or Statement.CLOSE_ALL_RESULTS are supplied as the argument.

也可以看看:

getMoreResults

Added in API level 1
boolean getMoreResults ()

移动到 Statement对象的下一个结果,如果它是 ResultSet对象,则返回 true ,并隐式关闭使用方法 getResultSet获取的所有当前 ResultSet对象。

当以下情况属实时,没有更多结果:

     // stmt is a Statement object
     ((stmt.getMoreResults() == false) && (stmt.getUpdateCount() == -1))
 

Returns
boolean true if the next result is a ResultSet object; false if it is an update count or there are no more results
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

也可以看看:

getQueryTimeout

Added in API level 1
int getQueryTimeout ()

检索驱动程序将等待Statement对象执行的Statement 如果超出限制,则引发SQLException

Returns
int the current query timeout limit in seconds; zero means there is no limit
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

也可以看看:

getResultSet

Added in API level 1
ResultSet getResultSet ()

ResultSet对象的形式检索当前结果。 每个结果只能调用一次该方法。

Returns
ResultSet the current result as a ResultSet object or null if the result is an update count or there are no more results
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

也可以看看:

getResultSetConcurrency

Added in API level 1
int getResultSetConcurrency ()

检索由此 ResultSet对象生成的 Statement对象的结果集并发性。

Returns
int either ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

getResultSetHoldability

Added in API level 1
int getResultSetHoldability ()

检索由此 ResultSet对象生成的 Statement对象的结果集可保存性。

Returns
int either ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

getResultSetType

Added in API level 1
int getResultSetType ()

检索由此 ResultSet对象生成的 Statement对象的结果集类型。

Returns
int one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

getUpdateCount

Added in API level 1
int getUpdateCount ()

以更新计数检索当前结果; 如果结果是ResultSet对象或没有更多结果,则返回-1。 每个结果只能调用一次该方法。

Returns
int the current result as an update count; -1 if the current result is a ResultSet object or there are no more results
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

也可以看看:

getWarnings

Added in API level 1
SQLWarning getWarnings ()

检索此Statement对象通过调用报告的第一个警告。 随后的Statement对象警告将被链接到此SQLWarning对象。

每次语句被重新执行时,警告链都会自动清除。 此方法不能在封闭的Statement对象上调用; 这样做会导致SQLException被抛出。

注意:如果您正在处理 ResultSet对象,则与该 ResultSet对象上的读取相关的任何警告都将链接在该对象上,而不是链接在产生该对象的 Statement对象上。

Returns
SQLWarning the first SQLWarning object or null if there are no warnings
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

isClosed

Added in API level 9
boolean isClosed ()

检索此Statement对象是否已关闭。 如果方法关闭已被调用,或者自动关闭,则关闭Statement

Returns
boolean true if this Statement object is closed; false if it is still open
Throws
SQLException if a database access error occurs

isPoolable

Added in API level 9
boolean isPoolable ()

返回一个值,指示 Statement是否可以 Statement

Returns
boolean true if the Statement is poolable; false otherwise

Throws
SQLException if this method is called on a closed Statement

也可以看看:

setCursorName

Added in API level 1
void setCursorName (String name)

将SQL游标名称设置为给定的String ,随后的Statement对象execute方法将使用该名称。 然后可以在SQL定位的更新或删除语句中使用此名称来标识由此语句生成的ResultSet对象中的当前行。 如果数据库不支持定位更新/删除,则此方法为noop。 为确保游标具有适当的隔离级别以支持更新,游标的SELECT语句应具有格式SELECT FOR UPDATE 如果FOR UPDATE不存在,定位更新可能会失败。

注意:根据定义,定位更新和删除的执行必须由与生成用于定位的ResultSet对象不同的Statement对象完成。 而且,游标名称在连接中必须是唯一的。

Parameters
name String: the new cursor name, which must be unique within a connection
Throws
SQLException if a database access error occurs or this method is called on a closed Statement
SQLFeatureNotSupportedException if the JDBC driver does not support this method

setEscapeProcessing

Added in API level 1
void setEscapeProcessing (boolean enable)

设置退出处理的开启或关闭。 如果转义扫描处于打开状态(默认状态),驱动程序会在将SQL语句发送到数据库之前执行转义替换。 注意:由于准备好的语句在进行此调用之前通常会被解析,因此禁用PreparedStatements对象的转义处理将不起作用。

Parameters
enable boolean: true to enable escape processing; false to disable it
Throws
SQLException if a database access error occurs or this method is called on a closed Statement

setFetchDirection

Added in API level 1
void setFetchDirection (int direction)

为驱动程序提供有关使用此Statement对象创建的对象在ResultSet对象中的处理方向的提示。 默认值是ResultSet.FETCH_FORWARD

请注意,此方法设置由此Statement对象生成的结果集的默认获取方向。 每个结果集都有自己的获取和设置自己获取方向的方法。

Parameters
direction int: the initial direction for processing rows
Throws
SQLException if a database access error occurs, this method is called on a closed Statement or the given direction is not one of ResultSet.FETCH_FORWARD, ResultSet.FETCH_REVERSE, or ResultSet.FETCH_UNKNOWN

也可以看看:

setFetchSize

Added in API level 1
void setFetchSize (int rows)

当此Statement ResultSet对象需要更多行时,向JDBC驱动程序提示应该从数据库中提取的行Statement 如果指定的值为零,则提示将被忽略。 默认值为零。

Parameters
rows int: the number of rows to fetch
Throws
SQLException if a database access error occurs, this method is called on a closed Statement or the condition rows >= 0 is not satisfied.

也可以看看:

setMaxFieldSize

Added in API level 1
void setMaxFieldSize (int max)

设置此ResultSet对象生成的Statement对象中可以返回字符和二进制列值的最大字节数限制。 此限制仅适用于BINARYVARBINARYLONGVARBINARYCHARVARCHARNCHARNVARCHARLONGNVARCHARLONGVARCHAR领域。 如果超出限制,则会过多丢弃超量数据。 为了获得最大的便携性,请使用大于256的值。

Parameters
max int: the new column size limit in bytes; zero means there is no limit
Throws
SQLException if a database access error occurs, this method is called on a closed Statement or the condition max >= 0 is not satisfied

也可以看看:

setMaxRows

Added in API level 1
void setMaxRows (int max)

设置由此ResultSet对象生成的任何Statement对象可包含的给定数量的最大行数限制。 如果超出限制,超出的行将被无声地丢弃。

Parameters
max int: the new max rows limit; zero means there is no limit
Throws
SQLException if a database access error occurs, this method is called on a closed Statement or the condition max >= 0 is not satisfied

也可以看看:

setPoolable

Added in API level 9
void setPoolable (boolean poolable)

要求将Statement合并或不合并。 指定的值是语句池实现的一个提示,指示应用程序是否希望语句被合并。 由声明池管理员决定是否使用提示。

一个语句的极大值适用于驱动程序实现的内部语句高速缓存和应用程序服务器和其他应用程序实现的外部语句高速缓存。

默认情况下, Statement在创建时 CallableStatementPreparedStatementCallableStatementCallableStatement创建时可以 CallableStatement

Parameters
poolable boolean: requests that the statement be pooled if true and that the statement not be pooled if false

Throws
SQLException if this method is called on a closed Statement

setQueryTimeout

Added in API level 1
void setQueryTimeout (int seconds)

将驱动程序等待Statement对象执行的秒数设置为给定秒数。 默认情况下,对于运行语句完成所允许的时间量没有限制。 如果超出限制,则抛出SQLTimeoutException JDBC驱动程序必须将此限制到executeexecuteQueryexecuteUpdate方法。

注意: JDBC驱动程序实现也可能将此限制应用于 ResultSet方法(有关详细信息,请参阅您的驱动程序供应商文档)。

注意:对于 Statement批处理,它的实现定义为超时是应用于通过 addBatch方法添加的单个SQL命令还是应用于由 executeBatch方法调用的整批SQL命令(请参阅驱动程序供应商文档了解详情)。

Parameters
seconds int: the new query timeout limit in seconds; zero means there is no limit
Throws
SQLException if a database access error occurs, this method is called on a closed Statement or the condition seconds >= 0 is not satisfied

也可以看看:

Hooray!