Android Question MSMySQL - App crash after Resume

Andreas_D99

Member
Licensed User
Hi,
I use MSMySQL Library to connect a local mysql Database. It works fine except one Error:
When I resume the App
a) after paused for a longer Time... (several Hours...), or
b) when the Device lost the Wifi-Connection and is reconnected

the App crashes with this Error:

B4X:
~i:** Activity (tische) Resume **
Tische IP: 192.168.0.3
Metadaten: (MyMap) {ms=620, TaskID=}
Metadaten: (MyMap) {ms=5, TaskID=UpdateSumme}
~i:** Activity (tische) Pause, UserClosed = false **
java.lang.Exception: Sub mysql_execresult signature does not match expected signature.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:188)
at anywheresoftware.b4a.BA$2.run(BA.java:360)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)

Can anybody help or explain this Error?
Thanks and best Regards...
 

DonManfred

Expert
Licensed User
Longtime User
Start with posting at the right forum...
This is the library forum and should not be used for questions!


Can anybody help or explain this Error?
Sub mysql_execresult signature does not match expected signature.
Check the signature
Based on my answer here it should be
B4X:
Sub MySQL_ExecResult(l As List, meta As Map)
    Log(meta) 
End Sub

Check Erels answer.... Switch to the new official library is most probably the best way to go.
I too switched to the new library.
 
  • Like
Reactions: eps
Upvote 0

Andreas_D99

Member
Licensed User
Now I found the Reason. If the Connection to the mysql-DB is lost, MSMyQL Library needs round about 10 Sec for reconnecting to the mysql-Database, if the User resume the App.
Is it possible to Block the App while reconnecting ? Or show a MessageBox within Try...Catch ? (I need a Brainstorming, I am an absolutly Newbie...)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Is it possible to Block the App while reconnecting ?
You should get an status update when the app lost connection.... If i remember correctly there is a property which shows the state.
Also note to have the status even sub implemented....
 
Upvote 0

Andreas_D99

Member
Licensed User
I think the Problem is, that the Database is intialized in the Main Activity, and so the mysql_status Sub in the Main Activity will be updated. But the Main Activty is paused at this moment, because the App will resumed in a other Activity.

And so the Status Update will be the send to a waiting queue. Is it possible to reach the mysql_status in the Main Activity? Or activate the mysql_status Sub in the resumed Activity?

B4X:
Tische IP: 192.168.0.3
~e:ReConnecting
Attempting Auto-Reconnect...
Raising.. mysql_status
sending message to waiting queue (mysql_status)
Auto-Reconnect Attempt #1 of 15
~e:ReConnecting
~e:MySQL Database not connected!
 
Upvote 0

Andreas_D99

Member
Licensed User
when the App resumed, a mysql Query will processed in the resumed Activity. But when the DB connection is lost, MSMySQL try to reconnect, but the Query is faster, so the App crash. Here the Log:

B4X:
Tische IP: 192.168.0.3
~e:ReConnecting
Attempting Auto-Reconnect...
Raising.. mysql_status
sending message to waiting queue (mysql_status)
Auto-Reconnect Attempt #1 of 15
~e:ReConnecting
~e:MySQL Database not connected!
lib:Exception:java.lang.NullPointerException: Attempt to invoke interface method 'java.sql.Statement java.sql.Connection.createStatement()' on a null object reference
SqlException: java.lang.NullPointerException: Attempt to invoke interface method 'java.sql.Statement java.sql.Connection.createStatement()' on a null object reference
~i:** Activity (tische) Pause, UserClosed = false **
~i:** Activity (tischartikel) Create, isFirst = false **
~i:** Activity (tischartikel) Resume **
~e:MySQL Database not connected!
lib:Exception:java.lang.NullPointerException: Attempt to invoke interface method 'java.sql.Statement java.sql.Connection.createStatement()' on a null object reference
SqlException: java.lang.NullPointerException: Attempt to invoke interface method 'java.sql.Statement java.sql.Connection.createStatement()' on a null object reference
~e:MySQL Database not connected!
lib:Exception:java.lang.NullPointerException: Attempt to invoke interface method 'java.sql.Statement java.sql.Connection.createStatement()' on a null object reference
MySQL_QueryResult((MyMap) {Error=Attempt to invoke interface method 'java.sql.Statement java.sql.Connection.createStatement()' on a null object reference, ColumnCount=0, RecordCount=0, TaskID=GetTischSumme, Exception=java.lang.NullPointerException: Attempt to invoke interface method 'java.sql.Statement java.sql.Connection.createStatement()' on a null object reference})
~e:MySQL Database not connected!
lib:Exception:java.lang.NullPointerException: Attempt to invoke interface method 'java.sql.Statement java.sql.Connection.createStatement()' on a null object reference
SqlException: java.lang.NullPointerException: Attempt to invoke interface method 'java.sql.Statement java.sql.Connection.createStatement()' on a null object reference
~e:java.lang.Exception: Sub mysql_execresult signature does not match expected signature.
~e: at anywheresoftware.b4a.BA.raiseEvent2(BA.java:188)
~e: at anywheresoftware.b4a.BA$2.run(BA.java:360)
~e: at android.os.Handler.handleCallback(Handler.java:739)
~e: at android.os.Handler.dispatchMessage(Handler.java:95)
~e: at android.os.Looper.loop(Looper.java:168)
~e: at android.app.ActivityThread.main(ActivityThread.java:5845)
~e: at java.lang.reflect.Method.invoke(Native Method)
~e: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
~e: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
java.lang.Exception: Sub mysql_execresult signature does not match expected signature.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:188)
at anywheresoftware.b4a.BA$2.run(BA.java:360)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:168)
at android.app.ActivityThread.main(ActivityThread.java:5845)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:687)
 
Upvote 0

OliverA

Expert
Licensed User
except this little Problem
I hope you realize that this problem is only a problem because you are using a technology in an environment that it is not meant for. It's not a bug in MSMySQL and you may even encounter these issues using JdbcSQL. The issue is that these technologies are not designed for, nor cope very well with, intermittent connectivity.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
except this little Problem...
- Expect to have had a disconnection in activity_resume
- Wait for an successfully status event. Only now you should start your query. (after making sure you have a connection).
 
Upvote 0

Andreas_D99

Member
Licensed User
@DonManfred
Now it works with a individually adjustable Timer to wait for the reconnection.

@Erel
I know, that it is the best Way to connect if needed and then disconnect. But for my App I need the Connection constantly.

Thanks for your Help and your Posts... for me as Newbee is everything helpful... :)
 
Upvote 0
Top