Hi again!

Today I tried extracting BLOBs via SQLiteJDBC using getBytes(). While
my testing BLOB obviously was stored correctly (as I checked with the
CLI, which returned the correct typeof(), lenth() and quote()
representation), I got the wrong number of bytes and an unrecognizable
byte array from the driver. This was solved by setting up the DB with
UTF8 encoding (PRAGMA encoding = "UTF-8";) instead of the default
UTF16. I'm a bit confused now, because from what I read in the SQLite
API reference sqlite3_column_bytes() should always return the correct
number of bytes for a BLOB, independend of DB encoding...?? Might this
be a SQLite bug?

Also according to the API reference (section "Results Values From A
Query", almost at the end), the correct order of invocation should be
"sqlite3_column_blob() followed by sqlite3_column_bytes()", while
NestedDB::column_blob() does it the other way round. However,
reversing the order didn't change anything on the result in both
encodings.

Then I implemented the RS::getBlob() methods using the only available
Blob implementation SerialBlob, which seems to work as well as
getBytes(), so I'd like to ask to test and integrate them:

--8><--
    public Blob getBlob(int col) throws SQLException {
        return new SerialBlob(db.column_blob(pointer,
markCol(col))); }
    public Blob getBlob(String col) throws SQLException {
        return getBlob(findColumn(col)); }
--><8--

However, using getBytes() to read a blob into an ImageIcon results in
one less line ;-)

--8><--
//Blob blob = cursor.getBlob(fieldName);
//icon = new ImageIcon(blob.getBytes(1, (int)blob.length()));
icon = new ImageIcon(cursor.getBytes(fieldName));
--><8--

Martin


--~--~---------~--~----~------------~-------~--~----~
Mailing List: http://groups.google.com/group/sqlitejdbc?hl=en
To unsubscribe, send email to [EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to