This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Build: NetBeans IDE Dev (Build 201405010001) VM: Java HotSpot(TM) 64-Bit Server VM, 23.21-b01, Java(TM) SE Runtime Environment, 1.7.0_21-b11 OS: Windows 7 User Comments: mkhramov: Ececute SQL select from SQLIte database using xerial/sqlite-jdbc driver Stacktrace: java.lang.NullPointerException at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:106) at org.sqlite.jdbc3.JDBC3ResultSet.getBinaryStream(JDBC3ResultSet.java:235) at org.netbeans.modules.db.dataview.util.DBReadWriteHelper.readResultSet(DBReadWriteHelper.java:226) at org.netbeans.modules.db.dataview.output.SQLExecutionHelper.loadDataFrom(SQLExecutionHelper.java:775) at org.netbeans.modules.db.dataview.output.SQLExecutionHelper.access$800(SQLExecutionHelper.java:84) at org.netbeans.modules.db.dataview.output.SQLExecutionHelper$1Loader.run(SQLExecutionHelper.java:173)
Created attachment 147121 [details] stacktrace
Please provide steps to reproduce: - what did you do? (executed SQLs) - can you provide a sample? In my tests it worked ok.
Product Version: NetBeans IDE Dev (Build 201411150001) Java: 1.8.0_20; Java HotSpot(TM) 64-Bit Server VM 25.20-b23 Runtime: Java(TM) SE Runtime Environment 1.8.0_20-b26 JDBC driver sqlite-jdbc4-3.8.2-SNAPSHOT.jar from xerial Issue still there I just do SELECT * FROM TableName and see this exception. Once I try to grab table structure I see Error Message Box with Unable to grab structure java.lang.NullPointerException. Once I do select from table field by field I found that only one field with BLOB type gives me exception mentioned in issue Hope this helps
Thank you for rechecking - ok, long story short: The driver is broken. The long story: The problem arises only when the field is null. From: http://grepcode.com/file/repo1.maven.org/maven2/org.xerial/sqlite-jdbc/3.8.5-pre1/org/sqlite/jdbc3/JDBC3ResultSet.java#JDBC3ResultSet.getBinaryStream%28int%29 getBinaryStream in this case just wraps a byte[] returned fro getBytes - this blows, if the field is set to null. In all fairness, this should really fixed in the driver (=> fetch getBytes into a local variable if that is null, return null and be done with it and don't try to wrap null with a ByteArrayInputStream). It would be nice if you could raise a bug with the developers. Normaly I'm against fixing driver bugs in the client, but in this case it so short, that its worth it (I think): # This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/matthias/NetBeansProjects/core-main # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: db.dataview/src/org/netbeans/modules/db/dataview/util/DBReadWriteHelper.java --- db.dataview/src/org/netbeans/modules/db/dataview/util/DBReadWriteHelper.java +++ db.dataview/src/org/netbeans/modules/db/dataview/util/DBReadWriteHelper.java @@ -223,7 +223,12 @@ case Types.LONGVARBINARY: case Types.BLOB: { // Load binary data as stream and hold it internally as a pseudoblob - InputStream is = rs.getBinaryStream(index); + InputStream is = null; + try { + is = rs.getBinaryStream(index); + } catch (NullPointerException ex) { + // The xerial sqlite-jdbc driver fails to return null and instead throws a NullPointer Exception + } if (is == null) { return null; } else { Grabbing the structure still does not work - looks as if asking sqlite for index info is not such a good idea - I won't fix that.
The fix was committed as: http://hg.netbeans.org/core-main/rev/2e10eb3019db I checked that fix works, but I'd like to ask you to verify the fix. In the next few days a nightly build will be done and a message is placed then in this bug. If you find the issue fixed, please change the status of this bug to VERIFIED. Please note: Grab structure will not work as described above - the driver just supplies not enougth information.
Integrated into 'main-silver', will be available in build *201502020002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/2e10eb3019db User: Matthias Blaesing <matthias42@netbeans.org> Log: #244313: Work-around BLOB bug in xerial sqlite jdbc driver (throwing NullPointerException on getBinaryStream instead of returning null)
My test DB opens and shows data now with NetBeans IDE Dev (Build 201502050002)