B4J Question [SOLVED] B4J 4.20, problems with sqllite, drop table causes ‘Table SQLLOOCKED’.

johnerikson

Active Member
Licensed User
Longtime User
I can create and use the table in runtime, but not drop the table.



B4X:
            Dim m As Map
            m.Initialize
            m.Put("ID", "INTEGER")
            m.Put("ImageID", "TEXT")
            jDBUtils.CreateTable(Main.dbImage, "tmpSel", M, "ID")
            sSQL = "INSERT INTO tmpSel VALUES (1, 'Img2032')"
            jDBUtils.sqlR(sSQL) ' work
            jDBUtils.DropTable(Main.dbImage, "tmpSel") 'doesn't work
            'java.sql.SQLException: [SQLITE_LOCKED]  A table in the database is locked (database table is locked)

More...............
If I dont stop the application and manually trying to create a table or modify data in a table with SQLLiteStudio it causes the following error:
[23:02:54] Could not commit table structure. Error message: Could not commit a database transaction. Details: database is locked

It looks like that the entire database is locked for some transactions.
What can cause this??
 

johnerikson

Active Member
Licensed User
Longtime User
Thank you!

I already suspected it, but unfortunately, I get the same problem. This occurs even if I restart the computer, and do nothing else but run the application!
 
Upvote 0

billzhan

Active Member
Licensed User
Longtime User
FYI : https://www.sqlite.org/cvstrac/wiki?p=DatabaseIsLocked

jDBUtils is a customized module from DBUtils ? I guess some sql is left pending, post the jDBUtils module if possible.

What's the java version(java -version) and OS?
B4X:
jDBUtils.sqlR(sSQL)

'DBUtils
Public Sub InsertMaps(SQL As SQL, TableName As String, ListOfMaps As List)
...
Try
    SQL.BeginTransaction
...

        SQL.TransactionSuccessful   'is this line missing?
    Catch
        Log(LastException)
        SQL.Rollback
    End Try

End Sub
 
Upvote 0

johnerikson

Active Member
Licensed User
Longtime User
Thanks!
Yes, I have read many comments about SQL. BeginTransaction and SQL. TransactionSuccessful and use it!
I can run the exact same code in B4A and works perfectly but .... If I use SQL. BeginTransaction and SQL. TransactionSuccessful and run the code in Galaxy S6 the database crashing!

With B4J I can’t get it to work whith this flow of code. I have tried all combinations with BeginTransaction, TransactionSuccessful, I have among other things read someware that if they run it once it works automatically. But nothing helps!

Installations:
I have C:\Program Files\Java\jdk1.8.0_65\bin\javac.exe installed and referenced.
SQLLite #AdditionalJar: sqlite jdbc 3.7.2
Lib jSQL 1.30 (B4J) and SQL 1.30 (B4A)

So what?
 
Upvote 0

johnerikson

Active Member
Licensed User
Longtime User
[Solved]problems with sqllite, drop table causes ‘Table SQLLOOCKED’.

Of 22 SQLLite-Select statements in the project I had forgotten one without closing the Resultset. It's enough to have serious problems to solve.
It is good that through the superb support varying thoughts on new solutions.
When I discovered that the code worked after copying my code into the attached example, remained me to debug more in my own code.
Now I understand how important it is to close all reultset after all SELECT statements when using SQLLite. Good to know!

Many thanks!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…