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.

Bug 237687 - Error code 20000, SQL state XCL18: Stream or LOB value cannot be retrieved more than once
Summary: Error code 20000, SQL state XCL18: Stream or LOB value cannot be retrieved mo...
Status: RESOLVED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 7.3.1
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Libor Fischmeistr
URL:
Keywords: PATCH_AVAILABLE
Depends on:
Blocks:
 
Reported: 2013-10-26 09:03 UTC by jirbol
Modified: 2013-10-31 08:36 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (49.78 KB, text/plain)
2013-10-26 09:03 UTC, jirbol
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jirbol 2013-10-26 09:03:00 UTC
Error on viewing (SELECT...) a CHAR FOR BIT DATA field with other than NULL value in a Derby database

Product Version = NetBeans IDE 7.3.1 (Build 201306052037)
Operating System = Windows XP version 5.1 running on x86
Java; VM; Vendor = 1.7.0_25
Runtime = Java HotSpot(TM) Client VM 23.25-b01
Comment 1 jirbol 2013-10-26 09:03:12 UTC
Created attachment 141583 [details]
IDE log
Comment 2 matthias42 2013-10-30 21:35:17 UTC
This is reproducible:

create table xy (tex char(20) for bit data);
insert into xy ( tex ) VALUES (X'01FF');
select * from APP.XY;
drop table xy;

I suggest to unify the BLOB/BINARY handling into using the stream methods. I would expect them to work better than the blob ones. To support the blob interface streaming has to be implemented so its sensible to expect streaming on the resultset to work. Accessing as a blob is indeed not the best idea if the database invalidates the result after the first access.

A quick google search found several document documenting binary access via getBinaryStream, some explicit support from dbms (informix, db2), none described problems.

Change in DBReadWriteHelper.java:

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -206,38 +206,8 @@
             case Types.VARBINARY:
             case Types.LONGVARBINARY:
             case Types.BLOB: {
-                // Try to get a blob object
+                // Load binary data as stream and hold it internally as a pseudoblob
                 try {
-                    Blob blob = rs.getBlob(index);
-                    
-                    if (blob == null) {
-                        return null;
-                    }
-
-                    Object result = null;
-                    
-                    if (! rs.wasNull()) {
-                        result = new FileBackedBlob(blob.getBinaryStream());
-                    }
-                    
-                    try {
-                        blob.free();
-                    } catch (java.lang.AbstractMethodError err) {
-                        // Blob gained a new method in jdbc4 (drivers compiled
-                        // against older jdks don't provide this methid
-                    } catch (SQLException ex) {
-                        // DBMS failed to free resource or does not support call
-                        // ignore this, as we can't do more
-                    }
-                    
-                    return result;
-                    // Ok - can happen - the jdbc driver might not support
-                    // blob data or can for example not provide a longvarbinary
-                    // as blob - so fall back to our implementation of blob
-                } catch (SQLException ex) {
-                } catch (java.lang.UnsupportedOperationException ex) {
-                }
-                try {
                     InputStream is = rs.getBinaryStream(index);
                     if (is == null) {
                         return null;
@@ -245,20 +215,9 @@
                         return new FileBackedBlob(is);
                     }
                 } catch (SQLDataException x) {
-                    // wrong mapping JavaDB JDBC Type -4
-                    try {
-                        String sdata = rs.getString(index);
-                        if (rs.wasNull()) {
-                            return null;
-                        } else {
-                            return sdata;
-                        }
-                    } catch (SQLException ex) {
-                        // throw the original SQLDataException intead of this one
                         throw x;
                     }
                 }
-            }
             case Types.LONGVARCHAR:
             case -16:
             case Types.CLOB:
Comment 3 Libor Fischmeistr 2013-10-31 08:36:32 UTC
Patch applied: http://hg.netbeans.org/core-main/rev/9c60c53d6f7f

Matthias, thanks you very much for the patch.