What is the best way to store image in ultraliteJ database? I am going to sync this data with sql server. I have tried long binary datatype to store image but that doesn't work. After the sync the image on sql server is broken. Please let me know if any one has done this. |
Here is how to insert data into a LONG BINARY field: PreparedStatement ps = conn.prepareStatement( "INSERT jdbsblob VALUES(?,?)" ); int cRid = 1; int cVal = 2; java.io.OutputStream ostream; byte[] blob_bytes = new byte[11]; ostream = ps.getBlobOutputStream( cVal ); for (int i = 0; i < blob_bytes.length; i++ ) { blob_bytes[i] = 1; } ostream.write( blob_bytes, 0, rowLens[r] ); ostream.close(); ps.execute(); can i extend this code for update query
(13 Jan '12, 17:10)
TEJ
You should just be able to change the INSERT statement to an UPDATE: PreparedStatement ps = conn.prepareStatement( "UPDATE jdbsblob SET col = ? WHERE pk=?" ); Then get a BlobOutputStream for parameter 1 (as the first question mark is the column holding the blob) and write to it, then close(). Finally, call ps.execute().
(16 Jan '12, 16:27)
Tom Slee
|
Could you tell us how the image is "broken" at SQL Server? For example: - Does the row get to SQL Server? - If so, is there anything at all in the image column for that row? - If so, is it roughly the right length?
Can i extend this code for update