B4J Question Why it doesn't work?

Marco Gioia

Member
Licensed User
Hi everyone,

could anyone help me to fix the following issue?


B4X:
#Region Project Attributes
   #MainFormWidth: 600
   #MainFormHeight: 600
   #AdditionalJar:  mysql-connector-java-5.1.34-bin.jar
#End Region

Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   
   Public mysql As SQL
   Private driver As String = "com.mysql.jdbc.Driver"
   Private jdbcUrl As String = "jdbc:mysql://127.0.0.1:3306"
   Private Username As String = "root"
   Private Password As String = "0paomar0"
   
   Dim mysql As SQL
   
End Sub

Sub AppStart (Form1 As Form, Args() As String)

Dim sql As String =  "select idTable01 from Table01"
Dim SenderFilter As Object

   Wait For (Connect) Complete (Success As Boolean)
   If Success Then   
       SenderFilter = mysql.ExecQueryAsync("mysql", sql, Null)
       Wait For (SenderFilter) mysql_QueryComplete (Success As Boolean, rs As ResultSet)
       If Success Then
           Do While rs.NextRow
               Log(rs.GetString("nome"))
           Loop
       End If
   End If    
   
   MainForm = Form1
   'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
   MainForm.Show
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


'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
   CloseConnection
   Return True
End Sub

Sub CloseConnection
   mysql.Close
End Sub
 

Attachments

  • conn.jpg
    conn.jpg
    338.1 KB · Views: 240
  • conn.jpg
    conn.jpg
    338.1 KB · Views: 254

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Sorry i saw your initialize,

In your url string write /yourdatabase after the ports to select the database
 
Upvote 0
Top