Android Question JdbcSQL app works in debug but not in release

atiaust

Active Member
Licensed User
Longtime User
Hi All,

My B4A app uses JdbcSQL to talk to a MySQL database on my local RPI server and performs flawlessly in debug mode but crashes in release mode.

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main$ResumableSub_Activity_Createresume (java line: 401)
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.Util.getInstance(Util.java:408)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:861)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2266)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2015)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:768)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:385)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:323)
at java.sql.DriverManager.getConnection(DriverManager.java:569)
at java.sql.DriverManager.getConnection(DriverManager.java:219)
at anywheresoftware.b4j.objects.SQL.Initialize2(SQL.java:56)
at JHS.ZbarBarcodeScanner.main$ResumableSub_Activity_Create.resume(main.java:401)
at JHS.ZbarBarcodeScanner.main._activity_create(main.java:375)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)

Can anyone provide any ideas.

Thanks
 

atiaust

Active Member
Licensed User
Longtime User
Thanks Erel,

This has allowed me to run the app in release mode.

For my education, what causes this?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
One of the differences between debug and release is that the NetworkOnMainThread check is disabled in debug mode.
So without thinking too much I recommended to try it with this check disabled.

Truth is that you should switch to SQL.InitializeAsync as you don't want to do any network stuff on the main thread.
 
Upvote 0
Top