Please help me, i could not connect MySql Server database, what's problem in below code ?
Region Project Attributes
#AdditionalJar: mysql-connector-java-5.1.34-bin
#BridgeLogger: true
#End Region
Sub Process_Globals
Public RemoteSQL As JdbcSQL
'MYSQL
Private driver As String = "com.mysql.jdbc.Driver"
Private jdbcUrl As String = "jdbc:mysql://localhost/petrosoft"
'Private jdbcUrl As String = "jdbc:mysql://127.0.0.1:3306/petrosoft?characterEncoding=utf8"
'Private jdbcUrl As String = "jdbc:mysql://192.168.8.4:3306/petrosoft"
Private Username As String = "rshah"
Private Password As String = "ic2202"
Dim ConnectTmStart As Long
Public ProgName = "PetroSoft" As String
Public ProgVersion = "1.1" As String
Public ProgAuthor = "Rakesh Shah - 9825292342" As String
Public ProgDate = "Apr 2020" As String
Public ProgCopyright = "Index Computers" As String
Public ProgCountry = "Vadodara,Gujarat, India" As String
Public ProgEMail = "rshah1610@yahoo.co.in" As String
Public PbUName As String
Public SQL1 As SQL
'Dim cursor1 As Cursor
Public DBFileName = "PetroSoft.db" As String
Public DBFileDir = File.DirInternal As String
'Public DBFileName = jdbcUrl As String
Public DBTableName As String
Public pbCompName = "MARATHON GAS" As String
Public pbDate,pbShift,pbActNm,pbCurBal As String
End Sub
Sub Globals
Private Label1 As Label
Private Panel1 As Panel
Private txtUName As EditText
Private txtPWord As EditText
Private cmdSubmit As Button
Private lblMsg As Label
Private cmdClose As Button
Private ImageView1 As ImageView
Private lblFooter As Label
Dim txt As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
Activity.Initialize("Main")
Activity.Title = "PetroSoft"
Label1.Text = pbCompName
lblFooter.Text = ProgAuthor
'DisableStrictMode
ConnectTmStart =DateTime.Now
lblFooter.Top =Activity.Height- lblFooter.Height
ProcVarIni
End Sub
Sub ProcVarIni
lblMsg.Text = ""
txtUName.Text =""
txtPWord.Text =""
txtUName.RequestFocus
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub cmdSubmit_Click
If RemoteSQL.IsInitialized = False Then
RemoteSQL.InitializeAsync("RemoteSQL", driver, jdbcUrl, Username, Password)
Wait For RemoteSQL_Ready (Success As Boolean)
If Success = True Then
Log("Connect is " & Success)
Else
Log("Check unfiltered logs for JDBC errors.")
End If
End If
DBTableName = "ActMst"
txt = "Select ActNm,ClBal,UName,PWord FROM " & DBTableName
txt = txt & " Where UName = '" & txtUName.Text & "'"
txt = txt & " and PWord = '" & txtPWord.Text & "'"
'RemoteSQL.InitializeAsync("RemoteSQL", driver, jdbcUrl, Username, Password)
'Wait For RemoteSQL_Ready (Success As Boolean)
'If Success = True Then
' Log("Success" & (DateTime.Now - ConnectTmStart))
'Else
' Log("Not Connected" & (DateTime.Now - ConnectTmStart))
'End If
Dim sf As Object = RemoteSQL.ExecQueryAsync("RemoteSQL", txt,Null)
Wait For (sf) RemoteSQL_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
If Success Then
Do While Crsr.NextRow
pbActNm=Crsr.Getstring("ActNm")
pbCurBal=Crsr.Getstring("ClBal")
Loop
Crsr.Close
StartActivity("Menu")
Else
lblMsg.Visible = True
lblMsg.Text = "Invalid User Name / Password "
lblMsg.TextColor = Colors.Red
Sleep(4)
txtUName.Text = ""
txtUName.RequestFocus
End If
End Sub
Region Project Attributes
#AdditionalJar: mysql-connector-java-5.1.34-bin
#BridgeLogger: true
#End Region
Sub Process_Globals
Public RemoteSQL As JdbcSQL
'MYSQL
Private driver As String = "com.mysql.jdbc.Driver"
Private jdbcUrl As String = "jdbc:mysql://localhost/petrosoft"
'Private jdbcUrl As String = "jdbc:mysql://127.0.0.1:3306/petrosoft?characterEncoding=utf8"
'Private jdbcUrl As String = "jdbc:mysql://192.168.8.4:3306/petrosoft"
Private Username As String = "rshah"
Private Password As String = "ic2202"
Dim ConnectTmStart As Long
Public ProgName = "PetroSoft" As String
Public ProgVersion = "1.1" As String
Public ProgAuthor = "Rakesh Shah - 9825292342" As String
Public ProgDate = "Apr 2020" As String
Public ProgCopyright = "Index Computers" As String
Public ProgCountry = "Vadodara,Gujarat, India" As String
Public ProgEMail = "rshah1610@yahoo.co.in" As String
Public PbUName As String
Public SQL1 As SQL
'Dim cursor1 As Cursor
Public DBFileName = "PetroSoft.db" As String
Public DBFileDir = File.DirInternal As String
'Public DBFileName = jdbcUrl As String
Public DBTableName As String
Public pbCompName = "MARATHON GAS" As String
Public pbDate,pbShift,pbActNm,pbCurBal As String
End Sub
Sub Globals
Private Label1 As Label
Private Panel1 As Panel
Private txtUName As EditText
Private txtPWord As EditText
Private cmdSubmit As Button
Private lblMsg As Label
Private cmdClose As Button
Private ImageView1 As ImageView
Private lblFooter As Label
Dim txt As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
Activity.Initialize("Main")
Activity.Title = "PetroSoft"
Label1.Text = pbCompName
lblFooter.Text = ProgAuthor
'DisableStrictMode
ConnectTmStart =DateTime.Now
lblFooter.Top =Activity.Height- lblFooter.Height
ProcVarIni
End Sub
Sub ProcVarIni
lblMsg.Text = ""
txtUName.Text =""
txtPWord.Text =""
txtUName.RequestFocus
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub cmdSubmit_Click
If RemoteSQL.IsInitialized = False Then
RemoteSQL.InitializeAsync("RemoteSQL", driver, jdbcUrl, Username, Password)
Wait For RemoteSQL_Ready (Success As Boolean)
If Success = True Then
Log("Connect is " & Success)
Else
Log("Check unfiltered logs for JDBC errors.")
End If
End If
DBTableName = "ActMst"
txt = "Select ActNm,ClBal,UName,PWord FROM " & DBTableName
txt = txt & " Where UName = '" & txtUName.Text & "'"
txt = txt & " and PWord = '" & txtPWord.Text & "'"
'RemoteSQL.InitializeAsync("RemoteSQL", driver, jdbcUrl, Username, Password)
'Wait For RemoteSQL_Ready (Success As Boolean)
'If Success = True Then
' Log("Success" & (DateTime.Now - ConnectTmStart))
'Else
' Log("Not Connected" & (DateTime.Now - ConnectTmStart))
'End If
Dim sf As Object = RemoteSQL.ExecQueryAsync("RemoteSQL", txt,Null)
Wait For (sf) RemoteSQL_QueryComplete (Success As Boolean, Crsr As JdbcResultSet)
If Success Then
Do While Crsr.NextRow
pbActNm=Crsr.Getstring("ActNm")
pbCurBal=Crsr.Getstring("ClBal")
Loop
Crsr.Close
StartActivity("Menu")
Else
lblMsg.Visible = True
lblMsg.Text = "Invalid User Name / Password "
lblMsg.TextColor = Colors.Red
Sleep(4)
txtUName.Text = ""
txtUName.RequestFocus
End If
End Sub