SQLite Cursors and Blob Issues

jimmyjace

Member
Licensed User
Longtime User
Hi all,

I have an B4A application that is happily reading and writing data to the database.

There is a sub that posts data to a web service which works fine 99% of the time. However, I am getting reports from clients that the following error occurs intermittantly.

An error has occurred in sub:main_vvvvvvvvvvv0 (java
line:3341)
java.lang.IllegalStateException: Couldn't read row 0,
col 3 from CursorWindow. Make sure the Cursor is
initialized correctly before accessing data from it.
Continue?

The column index it is referring to is a BLOB which is basically picture data taken by the camera.

I have attached some example code from the application. Some variable declarations might not be there, but it gives you an idea of the logic.

Any help would be appreciated on this.

Kind Regards,

Jason
 

Attachments

  • BlobExample.txt
    1.1 KB · Views: 433

jimmyjace

Member
Licensed User
Longtime User
How do I check the java source code?

Hi Erel,

How would I check the java source code? I've not done that before.

Cheers,

Jason
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Hi Jason,

I've just stared getting the same error although saw it with a string field before I converted it to a blob. I think it has something to do with memory issues - whether this is a sqllite or device thing I don't know.

I'm also saving a photo into the db prior to uploading to a webservice.

Fingers crossed one of us gets a solution!

Regards,

Jon
 
Upvote 0

jimmyjace

Member
Licensed User
Longtime User
Blob size limit and memory

Hi Jon,

It's funny you mention memory, I think that is the problem I am having.

Does anyone know if there is a limitation on the blob size in an SQLite database?

Before passing to the webservice I am base 64 encoding the blob bytes, it works most of the time but there are problems which I cannot seem to get over.

Cheers,

Jason
 
Upvote 0

jimmyjace

Member
Licensed User
Longtime User
SQLite Blob record issues

Hi All,

I have downloaded a trial version of SQLite Expert Professional and opened the database from the tablet.

I can not only see all the blob data but export to jpeg format.

There must be an issue with the ExecQuery or ExecQuery2 which returns a cursor and the memory as I have proved my SQLite database appears not to be corrupted.

Anyone have ideas on this as i'm a little stumped with what to try now.

Jason
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
There is a list of some limits here: Implementation Limits For SQLite

That may help you out.

I'd try looking for SqlLiteStudio - it's free, basic and seems to do the job.

BTW, on your app are there any string columns that might also have too much data in them - convert them to blob columns too... That seemed to solve the error for me. It could explain why you get the error occasionally.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
BTW, on your app are there any string columns that might also have too much data in them - convert them to blob columns too... That seemed to solve the error for me. It could explain why you get the error occasionally.

When dealing with Blob data, and I have problems to get my record content, I try to get each blob one by one, then the rest of columns and that works. It's obviously a memory limitation.
 
Upvote 0

jimmyjace

Member
Licensed User
Longtime User
SQLite Table Columns

Hi Jon,

Here's the structure of my table with the blob:

ObsMedia_ID (INT)
ObsMedia_ObsID (INT)
ObsMedia_TypeID (INT)
ObsMedia_Data (BLOB)
ObsMedia_Thumbnail (BLOB)

It fails once I check if the Blob for ObsMedia_Data or ObsMedia_Thumbnail IS NULL.
 
Upvote 0

jimmyjace

Member
Licensed User
Longtime User
Java Error - Loading record with Blob in SQLite

I have attached a screenshot of the error i get when loading the cursor record. This is not happening all the time, but more than often now.
 
Upvote 0

jimmyjace

Member
Licensed User
Longtime User
Loading blob's one by one

Hi,

I was loading that data using a cursor one-by-one anyway, so I don't think that was the problem.

However, I did notice that on the camera library I hadn't set the "setResolution" property, which inadvertantly caused the photos to be taken at full resolution.

Now I have changed this to 800x600 it's great and all blobs transfer to SQL no problems.

Cheers,

Jason
 
Upvote 0

joneden

Active Member
Licensed User
Longtime User
Hi Jason,

Yeah I'd tried that but it didn't seem to affect the end picture size - in the docs it says that it affects the preview picture size.

I can get the blob saved if I resize the bitmap - but that's slow and would love the setresolution to work!

Where are you setting it? After init, before preview etc?

Regards,

Jon
 
Upvote 0
Top