Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite Exception: Insert statement does not return a Statement

Tags:

java

sql

sqlite

I'm using SQLiteJDBC as the wrapper for an embedded database for my small Java app. Everytime I execute an INSERT statement, I get the following exception:

query does not return ResultSet

I am wondering if the JDBC Statement.executeStatement(String) method is looking for me to return a ResultSet, but that the SQLite driver knows that INSERT statements don't return anything; maybe SQLiteJDBC is throwing an error because it shouldn't be returning the ResultSet that Statement is asking for?!?

Here is the code that is producing the exception - I have made sure to setup and close all resources properly:

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

Any ideas?!?

like image 323
Massie Avatar asked Aug 13 '11 17:08

Massie


1 Answers

When you are making a change and not asking for a result back, you need to call executeUpdate() instead of executeStatement().

EDIT

I can't even find a reference to executeStatement() anywhere. Were you using executeQuery()?

like image 86
101100 Avatar answered Sep 22 '22 10:09

101100