sqlite-jdbc
sqlite-jdbc copied to clipboard
java.sql.SQLException: Query returns results when execute DDL statement
Enviroment:
Java 1.8org.xerial:sqlite-jdbc:3.31.1
Code:
import org.junit.Test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class SqliteBug {
@Test
public void bug() throws Exception {
final Connection c = DriverManager.getConnection(
"jdbc:sqlite::memory:"
);
final PreparedStatement stmt1 = c.prepareStatement(
"CREATE TABLE t (t TEXT)"
);
stmt1.executeUpdate();
stmt1.close();
final PreparedStatement stmt2 = c.prepareStatement(
"ALTER TABLE t RENAME TO t2"
);
stmt2.executeUpdate(); // java.sql.SQLException: Query returns results
stmt2.close();
}
}
Query returns results
java.sql.SQLException: Query returns results
at org.sqlite.jdbc3.JDBC3PreparedStatement.executeUpdate(JDBC3PreparedStatement.java:92)
at com.example.SqliteBug.bug(SqliteBug.java:31)
...
What type of result?
@michael-o I've jist updated the description. I think It should work without any exception.
That's interesting. Does it work with filebased DBs too? I assume that the create table statement returns 1 for the column created and that value is retained for the second run: https://github.com/xerial/sqlite-jdbc/blob/d28a8aaa4e1ca6d0795a2926b918d7c22c21cc2b/src/main/java/org/sqlite/core/CorePreparedStatement.java#L47
@michael-o Yes, for filebased DBs the same exception
That actually interesting, I am dumping a subset of an Oracle DB into SQLite with create table statements, but don't do any alter table.
This test works fine with h2 driver
Just tried the code above and it works on the latest master. I will close this.
Thanks!