Why do I get "Invalid Cursor State" errors when I insert/update/delete data with executeQuery()?

Joe Sam Shirah

The base answer is that you should be using executeUpdate() for these operations. The JDBC spec specifically "allows any query string to be passed through to an underlying DBMS driver" and this is probably why a number of databases will actually perform the requested operation. However, no ResultSet is returned. executeQuery() expects a ResultSet, and so reports the error when none is returned.