cancel
Showing results for 
Search instead for 
Did you mean: 

UltraliteJ database image field

Former Member
2,359

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.

Former Member
0 Kudos

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?

Former Member
0 Kudos

Can i extend this code for update

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member

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();
Former Member
0 Kudos

can i extend this code for update query

Former Member
0 Kudos

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().