On Mon, Apr 13, 2009 at 11:14:17AM -0700, Julian Bui wrote: > Hi all, > > I have a question about encoding blob bytes before inserting a record into > SQLite. > > CONTEXT: > I have a base java (I'm using JDBC) class that has a many children. Each > child may store a different data type (such as String, int, long, etc.) in > its VALUE field. Since this value field could be many different data types, > I will be storing the field's bytes into the database as a blob. > > QUESTIONS: > > -I have seen a couple of places on the internet saying that SQLite cannot > inserting binary data unless it has been encoded. Can someone confirm this > or preferrably point me to an OFFICIAL sqlite statement/page saying that > this is true?
As pointed out by others, SQLite is perfectly capable of storing unencoded BLOBS since SQLite 3.0 was released. > > -Will I need to encode my data? I do not think the String.getBytes() > command returns bytes including a terminator. However, since the terminator > is just 0, I assume that even storing the integer 0 as bytes in the blob > would be a problem. Is it not? Given your Java context, the most portable way to encode Java objects is to make them implement the Serializable interface, and store the serialized text representation in the column. However, if all you're doing is storing simple types and not complex data structures, this is overkill and you're best off just exploiting SQLite's manifest type system as pointed out in other replies. Cheers, Christian _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

