来源:[url]http://www.coderanch.com/t/301594/JDBC/java/Difference-between-execute-executeQuery-executeUpdate[/url]
boolean execute()
Executes the SQL statement in this PreparedStatement object, which may be any kind of SQL statement.
ResultSet executeQuery()
Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.
int executeUpdate()
Executes the SQL statement in this PreparedStatement object, which must be an SQL INSERT, UPDATE or DELETE statement; or an SQL statement that returns nothing, such as a DDL statement.
本文详细解释了JDBC中PreparedStatement对象的三种执行方法:execute、executeQuery与executeUpdate的区别及用法。execute方法用于执行任意SQL语句并返回布尔值;executeQuery专用于执行查询语句并返回ResultSet对象;executeUpdate则用于执行更新操作如插入、更新或删除,并返回受影响的行数。
631

被折叠的 条评论
为什么被折叠?



