I am getting this error in Release but not during Debug in my Web API Template when calling an API using ajax. I am using SQLite database.
B4X:
(SQLException) java.sql.SQLException: stmt pointer is closed
B4X:
Private Sub Search (SearchForText As String)
Dim con As SQL = Main.DB.GetConnection
Try
Dim List1 As List
List1.Initialize
Dim keys() As String = Regex.Split2(" ", 2, SearchForText)
If keys.Length < 2 Then
Dim s1 As String = SearchForText.Trim
'Log(s1)
If s1 = "" Then
Dim strSQL As String = $"SELECT P.id As aa, P.product_code As bb, C.`category_name` As cc, P.product_name As dd, P.product_price As ee, P.`category_id` As ff
FROM `tbl_products` P JOIN `tbl_category` C ON P.`category_id` = C.`id`"$
Dim res As ResultSet = con.ExecQuery(strSQL)
Else
Dim strSQL As String = Main.queries.Get("SEARCH_PRODUCT_BY_CATEGORY_CODE_AND_NAME_ONEWORD_ORDERED")
Dim res As ResultSet = con.ExecQuery2(strSQL, Array As String("%" & s1 & "%", "%" & s1 & "%", "%" & s1 & "%"))
End If
Else
Dim s1 As String = keys(0).Trim
Dim s2 As String = SearchForText.Replace(keys(0), "").Trim
'Log(s1 & "," & s2)
Dim strSQL As String = Main.queries.Get("SEARCH_PRODUCT_BY_CATEGORY_CODE_AND_NAME_TWOWORDS_ORDERED")
Dim res As ResultSet = con.ExecQuery2(strSQL, Array As String("%" & s1 & "%", "%" & s1 & "%", "%" & s1 & "%", _
"%" & s2 & "%", "%" & s2 & "%", "%" & s2 & "%"))
End If
Do While res.NextRow
Dim Map2 As Map
Map2.Initialize
For i = 0 To res.ColumnCount - 1
Select res.GetColumnName(i)
Case "aa"
Map2.Put(res.GetColumnName(i), res.GetInt2(i))
Case "ee"
Map2.Put(res.GetColumnName(i), NumberFormat2(res.GetDouble2(i), 1, 2, 2, True))
Case Else
Map2.Put(res.GetColumnName(i), res.GetString2(i))
End Select
Next
List1.Add(Map2)
Loop
res.Close
Utility.ReturnSuccess2(List1, 200, Response)
Catch
LogError(LastException)
HRM.ResponseCode = 422
HRM.ResponseError = "Error Execute Query " & LastException.Message
Utility.ReturnHttpResponse(HRM, Response)
End Try
Main.DB.CloseDB(con)
End Sub