Hello to all of you.
I finish a project using JDBC connection working just fine. (B4A.... The best....)
Yesterday I start a new project using again JDBC connection.
I did something simple... I copy from my previous project the class I had for JDBC connection.
I make some changes... everything was good since I debug my project for the first time.
The Connect sub return Success as true but the wait command not recognize it.
All the code is inside a class cold SyncClass
I post my code here cuz I need your help so I can find out what I do wrong.
I finish a project using JDBC connection working just fine. (B4A.... The best....)
Yesterday I start a new project using again JDBC connection.
I did something simple... I copy from my previous project the class I had for JDBC connection.
I make some changes... everything was good since I debug my project for the first time.
The Connect sub return Success as true but the wait command not recognize it.
All the code is inside a class cold SyncClass
I post my code here cuz I need your help so I can find out what I do wrong.
B4X:
Sub Connect As ResumableSub
RemoteSQL.InitializeAsync("RemoteSQL", driver, jdbcUrl, Username, Password)
Wait For RemoteSQL_Ready (Success As Boolean)
If Success = False Then
Log("Check unfiltered logs for JDBC errors.")
End If
Log("Connect is " & Success)
Return Success
End Sub
Sub CloseConnection
RemoteSQL.Close
End Sub
Sub ListItems_Update_Local_Check(Parent As CircularProgressBar)
Dim SQlScript As String
SQlScript = $"SELECT Code, TS FROM LOCAL_IItem"$
'Log(SQlScript)
Dim Curs1 As Cursor
Starter.LocalSQL.Initialize(File.DirRootExternal & "/DroidViewDB/", "DVD_Database.db", True)
Curs1 = Starter.LocalSQL.ExecQuery(SQlScript)
Main.G1.RowCounted = Curs1.RowCount
For i = 0 To Curs1.RowCount - 1
Curs1.Position = i
ListItems_Update(Curs1.GetString("Code"), Curs1.GetString("TS"), Parent, i, Curs1.RowCount)
Sleep(0)
Next
End Sub
Sub ListItems_Update(Code1 As String, TS1 As String, Parent1 As CircularProgressBar, ii As Int, T1 As Int) As ResumableSub
Parent1.Value = ii / T1
Wait For (Connect) Complete (Success As Boolean)
Log("It is :" & Success)
If Success Then
Try
Dim Qry As String
Qry = $"SELECT Code, Description FROM tem where Type in (0,12) And Code = '${Code1}' And Class = 1 TS <> '${TS1}'"$
Dim sf As Object = RemoteSQL.ExecQueryAsync("RemoteSQL", Qry, Null)
Wait For (sf) RemoteSQL_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
If Success Then
Dim i1 As Int = 1
Do While Crsr.NextRow
Starter.LocalSQL.ExecNonQuery2($"Update LOCAL_ESFIItem Set Code = ?, Description= ? WHERE Code = '${Code1}' AND TS <> '${TS1}'"$, _
Array As Object(Crsr.GetString("Code1"), Crsr.GetString("Description")))
i1 = i1 + 1
Sleep(0)
Loop
Crsr.Close
End If
Catch
Success = False
Log(LastException)
End Try
CloseConnection
End If
Return Success
End Sub