Android Question App crashes on Senderfilter execution.

Similar threads

B4A Tutorial [B4X] SQL with Wait For
B4A Tutorial SQL tutorial
B4A Question Sql Update
B4A Question ExecNonQueryBatch failing
B4A Question JdbcSQL failing insert with parameters

Enrico Fuoti

Member
Licensed User
I'm experiencing this strange crash.
Application that use to work fine with previous B4A versions, will not run when compiled with B4A 9.8 or B4A10.
It stops on "wait for (senderfilter)" execution.
Here is an example of the running code:

Example:
For Each records() As Object In res2.Rows
    ' some code
    ' ----
    ' ----
    '
    Starter.sql.AddNonQueryToBatch("delete from users where badge = ?", Array As Object(ls_badge)  )
    Starter.sql.AddNonQueryToBatch("Insert into users (rowid, cod_fiscale, ...) Values ( null,?,...)",Array As Object(ls_cod_fiscale, ...))
    sleep(0)
next
    Dim SenderFilter As Object = Starter.sql.ExecNonQueryBatch("sql")
    'never returns from following line
    'although sometimes it does, i don't know why
    Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
error message returned is
java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /data/user/0/com.watertech.main/files/watertech.db

I searched the forum but i couldn't fine any thread facing same issue.
can someone suggest a possible solution...?
 

Enrico Fuoti

Member
Licensed User
Clearing the log filter i was able to find out the real problem. The sql lite db gets corrupted and deleted..

"Corruption reported by sqlite on database: /data/user/0/com.watertech.main/files/watertech.db
The connection pool for /data/user/0/com.watertech.main/files/watertech.db has been closed but there are still 1 connections in use. They will be closed as they are released back to the pool."

Now the question is: Why the db gets corrupted ?
Any suggestion ?
 

Erel

Administrator
Staff member
Licensed User
Application that use to work fine with previous B4A versions, will not run when compiled with B4A 9.8 or B4A10.
Every time when a new version is released there are statements like this and in 99% of the cases they are wrong. Nothing has changed related to SQL in the new version.

You didn't provide enough information here to help you. Where does the connection pool come from?
 

Enrico Fuoti

Member
Licensed User
Hello Erel,
I understand the mood of your reply and i'm very likely in the 99% group.
I wrote it to give an hint, as this behaviour appeared after recompiling the app with newly installed version.
Said that, any new version may include bugs, but my statement didn't intend to be a convinced affirmation.
Believe me, before i write for help to the forum, i try for days to find a reason that may be related to a problem in my code.

You didn't provide enough information here to help you. Where does the connection pool come from?
I'm not sure to understand your question. Connection Pool message comes from the unfiltered log. It refers to the sql connection to the local sql lite db file.
I must say that after that, i tried replacing the two, delete and insert, sql statements with a single replace one.
This seems to have removed the problem. and application do not crash any longer.


Changed code:
    For Each records() As Object In res2.Rows
    ' some code
    ' ----
    ' ----
    ' this statements caused crash
    'Starter.sql.AddNonQueryToBatch("delete from users where badge = ?", Array As Object(ls_badge)  )
    'Starter.sql.AddNonQueryToBatch("Insert into users (rowid, cod_fiscale, ...) Values ( null,?,...)",Array As Object(ls_cod_fiscale, ...))
   
    'no crash with
    sql.AddNonQueryToBatch("replace into users (rowid, cod_fiscale, ... ) Values ( null,?,...)",Array As Object(ls_cod_fiscale, ... ))
   
    sleep(0)
next
    Dim SenderFilter As Object = Starter.sql.ExecNonQueryBatch("sql")
    'never returns from following line
    'although sometimes it does, i don't know why
    Wait For (SenderFilter) SQL_NonQueryComplete (Success As Boolean)
 

Enrico Fuoti

Member
Licensed User
Following your directives, I initialize it only once in starter module and i never close it.
I think it may be something related to internal sql lite engine.
 

Enrico Fuoti

Member
Licensed User
Thank You Erel,
it's not necessary. Of course you were right, as always.. :).
Nothing to do with the new version.
Using a new empty db seemed to have fixed the crash also with the delete/insert command.
Sorry, i did not try that before.
Thank you for your support. :)
 
Top