Today, I am using JSP + MYSQL to create an object. The following error occurs: Java. SQL. sqlexception: Can not issue data manipulation statements with executequery ().
My intention is to execute the following statement:
Stmt = conn. createstatement ();
Stmt.exe cutequery (SQL );
To insert data, so we encountered the above problem and finally found the cause:
If your SQL statement is an update statement such as update and insert, you should use the execute () method of statement. If you use the executequery () method of statement, an appeal problem will occur. The reason is:
Resultset executequery (string SQL); throws sqlexception
Execute the given SQL statement, which returns a single resultset object. Parameter: SQL-the SQL statement to be sent to the database. It is usually returned by the static SQL SELECT statement: the resultset object that contains the data generated by the given query; it cannot be null. Throw: sqlexception-if a database access error occurs or a given
SQL statements generate any content other than a single resultset object. In short, the query statement uses executequery (SQL) and the update statement uses execute (). Therefore, you only need to change the code executequery (update_ SQL) to execute (update_ SQL.