Hello people,
I am trying to communicate with the Firebird bank, using JDBC, as it is simpler and more straightforward, without having to install another tool on the client's machine, but I am not succeeding.
He just stands there, waiting for an answer on the line:
Wait For MySQL_Ready (Success As Boolean)
Follow the code I'm using, can someone help me?
I am trying to communicate with the Firebird bank, using JDBC, as it is simpler and more straightforward, without having to install another tool on the client's machine, but I am not succeeding.
He just stands there, waiting for an answer on the line:
Wait For MySQL_Ready (Success As Boolean)
Follow the code I'm using, can someone help me?
B4X:
#Region Service Attributes
#StartAtBoot: False
#ExcludeFromLibrary: True
#End Region
Sub Process_Globals
Public mysql As JdbcSQL
Private driver As String = "org.firebirdsql.jdbc.FBDriver"
Private jdbcUrl As String = "jdbc:firebirdsql://10.0.1.4:3050/C:/Users/admin/Desktop/JdbcSQL/db/TESTE_OFC.FDB"
Private Username As String = "sysdba"
Private Password As String = "masterkey"
End Sub
Sub Service_Create
'need to disable it as reading from large JdbcResultSet will cause network requests to be sent on the main thread.
DisableStrictMode
End Sub
Sub Service_Start (StartingIntent As Intent)
End Sub
Sub DisableStrictMode
Dim jo As JavaObject
jo.InitializeStatic("android.os.Build.VERSION")
If jo.GetField("SDK_INT") > 9 Then
Dim policy As JavaObject
policy = policy.InitializeNewInstance("android.os.StrictMode.ThreadPolicy.Builder", Null)
policy = policy.RunMethodJO("permitAll", Null).RunMethodJO("build", Null)
Dim sm As JavaObject
sm.InitializeStatic("android.os.StrictMode").RunMethod("setThreadPolicy", Array(policy))
End If
End Sub
Sub Connect As ResumableSub
mysql.InitializeAsync("mysql", driver, jdbcUrl, Username, Password)
Wait For MySQL_Ready (Success As Boolean)
If Success = False Then
Log("Check unfiltered logs for JDBC errors.")
End If
Return Success
End Sub
Sub CloseConnection
mysql.Close
End Sub
Sub select_teste_firebird As ResumableSub
Wait For (Connect) Complete (Success As Boolean)
If Success Then
Try
Dim sf As Object = mysql.ExecQueryAsync("mysql", "SELECT * FROM clientes ", Null)
Wait For (sf) mysql_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
If Success Then
Do While Crsr.NextRow
Log($"Id: ${Crsr.GetInt("id")}, Name: ${Crsr.GetString("nome")}"$)
Loop
Crsr.Close
End If
Catch
Success = False
Log(LastException)
End Try
CloseConnection
End If
Return Success
End Sub