B4J Question Websocket & Sqlite

jinyistudio

Well-Known Member
Licensed User
Longtime User
following code is a event, raise from web client.

B4X:
<script language="JavaScript">
            function button_click(n) {
                b4j_raiseEvent("button_click", {"name": n});
            };
        </script>
In the button_click,I have call sql update command. but it always give me message as "sql:updateAlarm, Exp:java.sql.SQLException: database is locked". Why ... ? in other place,I call it. it is OK.

B4X:
Sub button_click(Params As Map)
    If Params.Size<1 Then Return
    Dim event As String=Params.Get("name")
    Log("aldb button click:"&event)
    If event=Null Then Return
    '
    Dim ft1 As Future=alid.Getval
    Dim ft2 As Future=alcn.Getval
    Dim n1 As Int=ft1.Value
    Dim s1 As String=ft2.Value
   
    If Not(IsNumber(ft1.Value)) Then
        Log("button_click alid:"&ft1.Value&", alcn:"&ft2.Value)
        Return
    End If
   
    If event="load" Then
        Dim s1 As String=aldb.loadAlarm(n1)
        alcn.SetVal(s1)
        ws.Flush
       
    else if event="insert" Then
        If ft2.Value=Null Then Return
        CallSubDelayed3(aldb,"insertAlarm",n1,s1)
       
    else if event="update" Then
        If ft2.Value=Null Then Return
        CallSubDelayed3(aldb,"updateAlarm",n1,s1)
       
    else if event="delete" Then
        aldb.deleteAlarm(ft1.Value)
       
    End If
   
End Sub
 

jinyistudio

Well-Known Member
Licensed User
Longtime User
The SQL related code put in other one "Code Module".
 
Upvote 0
Top