Android Question Check unfiltered logs for JDBC errors. could not connect MySQL

rshah1610

Member
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
 

OliverA

Expert
Licensed User
Longtime User
Private jdbcUrl As String = "jdbc:mysql://localhost/petrosoft"
localhost means you’re trying to access the database running on your phone. Pretty sure that’s not what you are intending to do
 
Upvote 0

rshah1610

Member
Yes, i am trying to access the database on phone, i have also tried with MySQL Server Port 'Private jdbcUrl As String = "jdbc:mysql://127.0.0.1:3306/petrosoft?characterEncoding=utf8"
that is also not responding, giving error... "Check unfiltered logs for JDBC error"



thank you for your reply, please if solution give support me.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
No sir, MYSQL Server not running on phone, but how to run MYSQ in phone i don't know, it is required to run in phone ?
You are not able to run mysql on the phone.

The MySQL must run on a Server/VPS to then connect to it using jdbcsql.

The suggested solution is to use jRDC2 on your Server/VPS and connect to the MySQL-Server from within the jRDC2-Server.
You Phoneapp connect to your jRDC2 Server then.
 
Upvote 0
Top