Jdbc Update Statement Not Working In Netbeans But Working In Sql
I extract data from one database, execute a couple of checks and want to update a table in another database. My update.executeQuery statement is not working. However when I copy th
Solution 1:
This line
statementUpdate.executeQuery(OrderObject.updateString);
looks wrong to me. Try
statementUpdate.executeUpdate(OrderObject.updateString);
instead.
UPDATE statements are not queries, so you don't use executeQuery() with them. executeQuery() returns a ResultSet, but with an UPDATE statement there's no data to return. Instead, you use executeUpdate(). (Note that you also use executeUpdate() to run INSERT and DELETE statements - there aren't any executeInsert() nor executeDelete() methods on Statement objects.)
How databases behave in these situations varies from one database to another. In particular, the MySQL JDBC driver throws an exception with the following message if you attempt to use executeQuery() with an UPDATE statement:
Can not issue data manipulation statements with executeQuery()
Post a Comment for "Jdbc Update Statement Not Working In Netbeans But Working In Sql"