SQLite Exception: Insert statement does not return statement

I am using SQLiteJDBC as a shell for the embedded database for my small Java application. Every time I execute an INSERT statement, I get the following exception:

request does not return ResultSet

I am wondering if the JDBC Method Statement.executeStatement (String) is trying to return a ResultSet, but the SQLite driver knows that the INSERT statements do not return anything; perhaps SQLiteJDBC throws an error because it should not return the ResultSet requested by the query?!?

Here is the code that throws the exception - I will definitely install and close all resources properly:

statement = con.createStatement(); String sql = "INSERT INTO widgets (widget_age) VALUES (27)"; statement.executeStatement(sql); 

Any ideas?!?

+4
source share
2 answers

When you make changes and do not ask to return the result, you need to call executeUpdate() instead of executeStatement() .

EDIT

I can’t even find a link to executeStatement() anywhere. Have you used executeQuery() ?

+14
source

Sqlite always returns a message when you execute a query.

It is normal to have this warning / error, just so that no line is returned, so you cannot use them in a callback if you defined it.

PD: I also think you meant executeQuery

0
source

All Articles