B4J Question 2 errors - database connection closed and [SQLITE_MISUSE] Library used incorrectly (out of memory)

crazy_pvg

New Member
Hii there folks!

- I created a project for learning b4xpages working. In b4a it is crashing sometimes but not giving
any error message in logs and crashes happens only 10% times. But 90% times it is working perfectly in b4a.

- But in b4j it is crashing all the times and giving following error message.

- file for code of b4xmainpage module where i am working and the error message file are attached here.
 

Attachments

  • code of b4xmainpage module.txt
    1.6 KB · Views: 111
  • error message.txt
    36.4 KB · Views: 114

roerGarcia

Active Member
Licensed User
Longtime User
From here in stackoverflow
17

Your open routine is only creating/opening the database if the database doesn't exist. Your database probably already exists and thus your routine isn't even opening it.
Bottom line, if you try calling SQLite functions without opening the database, you will get the SQLITE_MISUSE return code (which indicates that the SQLite functions were not called in the right order) and the sqlite3_errmsg will return the cryptic "out of memory" error.

so probably the information you intend to put into the table does not exist.
check the result of the download before uploading it to the table.
 
Last edited:
Upvote 0

crazy_pvg

New Member
- first thanks @roerGarcia and @Erel for your precious reply to my post and sorry for late reply from my side.
- lets come to the point - i solved the error by following below steps.
- after i posted above problem to the forum. I got different error in logs section like this - IllegalMonitorStateException.
- So i searched for it on the forum.
- @Erel as you said in this post - https://www.b4x.com/android/forum/t...e-locked-illegalmonitorstateexception.123101/
(move the specific code outside the loop. First you create a list with all the data and then you insert it with a single call.)
- i moved this code outside the for loop - B4XTable1.SetData(l) 'l is my list name.
- and after it app crashing is stopped in B4a and b4j both.
- below i posted code of before error is solved and after error is solved.

Before error is solved:
Dim j As HttpJob
j.Initialize("", Me)

j.Download("https://mysitename/?paramter_name=paramter_passed")
    
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
    Dim rtest As String
    'Log(j.GetString)
    rtest=j.GetString
    rtest=rtest.SubString(22)
    'Log(rtest)
        
    Dim parser As JSONParser
    'parser.Initialize(j.GetString)
    parser.Initialize(rtest)
            
    Dim l As List
    l.Initialize
            
    Dim Root2 As Map = parser.NextObject
    Dim data As List = Root2.Get("data")
        
    
    For Each coldata As Map In data
        
        Dim Userparamter1 As String = coldata.Get("paramter1")
        Dim Userparamter2 As String = coldata.Get("paramter2")
            
        If Userparamter1<>"1" Then
            l.Add(Array(Userparamter1 , Userparamter2))
            B4XTable1.SetData(l)
            'l.Clear
        End If
    Next
    
    Dim status As String = Root2.Get("status")
        
        
Else
    'Msgbox("Please connect to internet","")
    xui.MsgboxAsync("Please connect To internet","")
End If
    
j.Release

After error is solved:
Dim j As HttpJob
j.Initialize("", Me)

j.Download("https://mysitename/?paramter_name=paramter_passed")
    
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
    Dim rtest As String
    'Log(j.GetString)
    rtest=j.GetString
    rtest=rtest.SubString(22)
    'Log(rtest)
        
    Dim parser As JSONParser
    'parser.Initialize(j.GetString)
    parser.Initialize(rtest)
            
    Dim l As List
    l.Initialize
            
    Dim Root2 As Map = parser.NextObject
    Dim data As List = Root2.Get("data")
        
    
    For Each coldata As Map In data
        
        Dim Userparamter1 As String = coldata.Get("paramter1")
        Dim Userparamter2 As String = coldata.Get("paramter2")
            
        If Userparamter1<>"1" Then
            l.Add(Array(Userparamter1 , Userparamter2))
            
            'l.Clear
        End If
    Next
    B4XTable1.SetData(l)
    Dim status As String = Root2.Get("status")
        
        
Else
    'Msgbox("Please connect to internet","")
    xui.MsgboxAsync("Please connect To internet","")
End If
    
j.Release
 
Upvote 0
Top