I have a long binary field in an Android UltraliteJ database and when I insert a value into it the byte array is around 800-900K in length. However, when I select it out it's less than 64K and not an image. The length returned varies depending on the length of the byte array I inserted. If I compress the image so it's around 20K it is returned from the select statement as the same size and is displayed as an image.

The database is in the applications Data folder on a Galaxy Nexus, Android version 4.0.1.

This is version 12.0.1.3537.

Is this is a bug or are long binary columns limited to 64k on Android?

Thanks, Jonathan

EDIT I've tried both resultset.getBytes(x) and resultset.getBlobInputStream and both have returned the same byte array (the wrong one).

EDIT(Calvin)

PreparedStatement command_statement; 
command_statement = connection.prepareStatement(commandText); 
command_statement.set(x + 1, byteArray); 
Log.v("Test","Insert Byte Array - " + Integer.toString(byteArray.length));

asked 17 Apr '12, 16:43

J%20Chapman's gravatar image

J Chapman
3413612
accept rate: 66%

edited 18 Apr '12, 13:16

Calvin%20Allen's gravatar image

Calvin Allen
1.5k232638

Please add the details, how you currently try to read the blob data

(18 Apr '12, 03:08) Martin
Comment Text Removed

Post the code you are using.

(18 Apr '12, 08:48) Calvin Allen

Further, please post the code that you are using for both write and read of the binary column. There was a bug, fixed in 12.0.1.3540, with PreparedStatement.set() with a String parameter - see CR 693856. However, this may be a different issue. Thanks.

(18 Apr '12, 09:23) Andy Quick

After reviewing the consolidated database it is the insert that is failing. If I take the bytearray that I pass to the set method it's 707784 long. If I look in the consolidated database it's 52424. The code we use for the insert is

PreparedStatement command_statement; command_statement = connection.prepareStatement(commandText); command_statement.set(x + 1, byteArray); Log.v("Test","Insert Byte Array - " + Integer.toString(byteArray.length));

(18 Apr '12, 10:35) J Chapman

I just updated to 3605 with no change in the result.

(18 Apr '12, 12:20) J Chapman
Comment Text Removed

After consulting with Chris, I have determined that this is a bug with PreparedStatement.set(int,byte[]). The byte array is limited to 32 KB in size right now. I will fix that in an upcoming release. There is no such limitation on long binary columns in UltraLite databases, and, as a workaround, you could use PreparedStatement.getBlobOutputStream(int) to get a java.io.OutputStream, and use that to write the value into the long binary field. Thanks.

permanent link

answered 18 Apr '12, 13:53

Andy%20Quick's gravatar image

Andy Quick
2.2k2737
accept rate: 45%

Do you have a engineering number to track this bug? I doesn't look like it was fixed in the April 30th release. Thanks

(02 May '12, 16:26) dmck

The engineering case is 705696 and was addressed in 12.0.1.3721 or later. The EBF released on April 30th is 12.0.1.2718 and as such does not include this change.

(02 May '12, 16:30) Chris Keating
Replies hidden

FWIW, the CR description is here.

(03 May '12, 03:22) Volker Barth
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×145
×77
×62

question asked: 17 Apr '12, 16:43

question was seen: 1,387 times

last updated: 03 May '12, 03:22