Issue #101 new

NPE in ResultSet.getBinaryStream when column has NULL value

Mingun
created an issue

Constructor of ByteArrayInputStream throw NullPointerException, if byte[] argument is null.

java.lang.NullPointerException
    at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:106)
    at org.sqlite.RS.getBinaryStream(RS.java:356)
    at org.sqlite.RS.getBinaryStream(RS.java:363)

Comments (2)

  1. Anthony O.

    Same issue here, this is really anoying because it makes it incompatible with Quartz (using sqlite-jdbc as backend). Here is the failing test case :

    import java.io.File;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    
    import org.apache.commons.io.IOUtils;
    
    
    public class Test {
    
        public static void main(String[] args) throws SQLException, IOException {
            Connection connection = DriverManager.getConnection("jdbc:sqlite:/tmp/test.db");
            Statement statement = connection.createStatement();
            statement.executeUpdate("create table qrtz_job_details (job_name varchar(200) not null, job_data blob, primary key (job_name))");
            statement.close();
    
            PreparedStatement prepareStatement = connection.prepareStatement("insert into qrtz_job_details (job_name, job_data) values (?, ?)");
            prepareStatement.setString(1, "test");
            prepareStatement.setBytes(2, new byte[0]);
            prepareStatement.executeUpdate();
            prepareStatement.close();
    
            statement = connection.createStatement();
            ResultSet resultSet = statement.executeQuery("select job_data from qrtz_job_details");
            resultSet.next();
            System.out.println(IOUtils.toString(resultSet.getBinaryStream("job_data")));
    
            connection.close();
    
            new File("/tmp/test.db").delete();
        }
    
    }
    
  2. Log in to comment