Cannot issue data manipulation statements with executeQuery()

silverkid picture silverkid · Dec 15, 2009 · Viewed 194.3k times · Source

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

executeQuery(query1) 
executeQuery(query2)

But I get the following error:

can not issue data manipulation statements with executeQuery().

What does this mean?

Answer

BalusC picture BalusC · Dec 15, 2009

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

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

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.