B4J Question Using jSQL to Lock a mySQL table for writing

MegatenFreak

Active Member
Licensed User
Hello.
I'm writing an app that allows several computers to add new orders to the database. To avoid any conflicts, I want to make sure that when one system is adding a new list of orders, no others can interrupt and will have to wait for the first one to finish up. I understand that the most straightforward way for it is to use the SQL command "LOCK TABLE mytable WRITE;" and once finished: "UNLOCK TABLES;"

I'm using mySql and InnoDB.
What I want to know is that will these commands work when passed as a query to jSQL? In other words, can I use the following code:
B4X:
sql1.BeginTransaction
Try
    sql1.ExecQuery("LOCK TABLE mytable WRITE")
    'Do both reading and writing operations on the database....
    '.......
    sql1.ExecQuery("UNLOCK TABLES")
Catch
    Log(LastException.Message)
    sql.RollBack
EndTry

If that works, yaaay! If it doesn't, how else can I do it conveniently?

Thank you so much in advance.
 
Top