Can not issue data manipulation statements with executeQuery



I’m getting an error when im trying to run my gui to inset data into a table, the error being Can not issue data manipulation statements with executeQuery(). The goal of this gui is to get the user to input information into the text area and then click submit and this information is uploaded to the database.

error : java.sql.SQLException: Can not issue data manipulation statements with executeQuery().

Answer

You have to use this method PreparedStatement#executeUpdate() instead of executeQuery

Executes the SQL statement in this PreparedStatement object, which
must be an SQL Data Manipulation Language (DML) statement, such as
INSERT, UPDATE or DELETE; or an SQL statement that returns nothing,
such as a DDL statement.



Source: stackoverflow