JAVA 中的SQL执行方法

本文详细解释了JDBC中PreparedStatement对象的三种执行方法:execute、executeQuery与executeUpdate的区别及用法。execute方法用于执行任意SQL语句并返回布尔值;executeQuery专用于执行查询语句并返回ResultSet对象;executeUpdate则用于执行更新操作如插入、更新或删除,并返回受影响的行数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

来源:[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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值