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

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

问题描述

在MySQL中我有两个表, tableA tableB 。我正在尝试执行两个查询:

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天全站免登陆