Interface PreparedStatement的execute(), executeQuery(), executeUpdate()方法

[b]execute[/b]
boolean execute()
throws SQLException
Executes the SQL statement in this PreparedStatement object, which may be any kind of SQL statement. Some prepared statements return multiple results; the execute method handles these complex statements as well as the simpler form of statements handled by the methods executeQuery and executeUpdate.
The execute method returns a boolean to indicate the form of the first result. You must call either the method getResultSet or getUpdateCount to retrieve the result; you must call getMoreResults to move to any subsequent result(s).


Returns:
true if the first result is a ResultSet object; false if the first result is an update count or there is no result
Throws:
SQLException - if a database access error occurs; this method is called on a closed PreparedStatement or an argument is supplied to this method
See Also:
Statement.execute(java.lang.String), Statement.getResultSet(), Statement.getUpdateCount(), Statement.getMoreResults()

----------------------------------------------------------------------

[b]executeQuery[/b]
ResultSet executeQuery()
throws SQLException
Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.

Returns:
a ResultSet object that contains the data produced by the query; never null
Throws:
SQLException - if a database access error occurs; this method is called on a closed PreparedStatement or the SQL statement does not return a ResultSet object

----------------------------------------------------------------------

[b]executeUpdate[/b]
int executeUpdate()
throws SQLException
Executes the SQL statement in this PreparedStatement object, which must be 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:
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 PreparedStatement or the SQL statement returns a ResultSet object
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值