Hi there to all,
something strange happens or somewhere i am wrong (as always)...
This is my code:
I am getting the following (if i am querying right password for ex. test):
If i have wrong password the app return the toastmessage with wrong user/pass
So where i am having problem ?
something strange happens or somewhere i am wrong (as always)...
This is my code:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim db As MSMaria
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Button1 As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
If FirstTime=True Then
db.DisableReconnect
db.Initialize("MySQL","192.168.168.3:3306","myroot","mypass","mydatabase")
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub MySQL_Status(Connected As Boolean, ReConnecting As Boolean, RetriesLeft As Int)
Log($"Connected = ${Connected}"$)
If Connected=True Then
'i will have a simple routine to remove escape chars
db.QueryASync("select * from cars WHERE id='myid' AND password='test';","login") 'The right one is test - but i am getting strange error
db.EnableReconnect
End If
End Sub
Sub MySQL_QueryResult(data As List, meta As Map)
Log(meta)
Dim m As Map = meta
Select Case m.Get("TaskID")
Case "login"
If data.size > 0 Then
ToastMessageShow("ok!",True)
db.ExecuteASync("UPDATE INTO cars SET login=1, lastdate='"& DateTime.Date(DateTime.Now) &"', lasttime='"& DateTime.time(DateTime.Now) & "' WHERE id='myid';","")
Else
ToastMessageShow("wrong user/pass",True)
End If
End Select
End Sub
I am getting the following (if i am querying right password for ex. test):
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Raising.. mysql_status
Connected to Database
** Activity (main) Resume **
Connected = true
lib:queryasync()
lib:Exception:java.lang.NullPointerException: Attempt to invoke virtual method 'double java.math.BigDecimal.doubleValue()' on a null object reference
null
main_mysql_queryresult (java line: 377)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object anywheresoftware.b4a.objects.collections.Map.Get(java.lang.Object)' on a null object reference
at b4a.example.main._mysql_queryresult(main.java:377)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.BA$2.run(BA.java:360)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5624)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
If i have wrong password the app return the toastmessage with wrong user/pass
So where i am having problem ?