无法使用 executeQuery() 发出数据操作语句 [英] Cannot issue data manipulation statements with executeQuery()

查看:32
本文介绍了无法使用 executeQuery() 发出数据操作语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 MySQL 中,我有两个表,tableAtableB.我正在尝试执行两个查询:

In MySQL I have two tables, tableA and tableB. I am trying to execute two queries:

executeQuery(query1) 
executeQuery(query2)

但我收到以下错误:

can not issue data manipulation statements with executeQuery().

这是什么意思?

推荐答案

要操作您实际需要的数据 executeUpdate() 而不是 executeQuery().

To manipulate data you actually need executeUpdate() rather than executeQuery().

这里是 executeUpdate() javadoc 的摘录,它本身就是一个答案:

Here's an extract from the executeUpdate() javadoc which is already an answer at its own:

执行给定的 SQL 语句,可以是 INSERT、UPDATE 或 DELETE 语句,也可以是不返回任何内容的 SQL 语句,例如 SQL DDL 语句.

Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.

这篇关于无法使用 executeQuery() 发出数据操作语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆