The method getObject in RS class processes null value incorrectly.

Issue #81 new
Anonymous created an issue

The method DO NOT update lastCol field where value is SQLITE_NULL. In this situation, wasNull return wrong value.

Comments (1)

  1. escabe

    The following code illustrates this issue (at least I think we are talking about the same issue here):

    public class MainClass {
        public static void main(String[] args) throws ClassNotFoundException {
            Connection connection = null;
            try {
                connection = DriverManager.getConnection("jdbc:sqlite:sample.db");
                Statement statement = connection.createStatement();
                statement.executeUpdate("drop table if exists example");
                statement.executeUpdate("create table example (col1 blob, col2 integer)");
                statement.executeUpdate("insert into example values(null,42)");
                ResultSet rs = statement.executeQuery("select * from example");
                while( {
                    Object blobdata = rs.getObject(1);
                    if (rs.wasNull()) {
                        System.out.println("BLOB was null");
                    } else {
            } catch (SQLException e) {

    As this will throw an exception:

    java.sql.SQLException: column -1 out of bounds [1,2]
        at org.sqlite.RS.checkCol(
        at org.sqlite.RS.markCol(
        at org.sqlite.RS.wasNull(
        at MainClass.main(
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
        at com.intellij.rt.execution.application.AppMain.main(
  2. Log in to comment