[Chargeable] MSMariaDB - Another connector to MySQL

jahswant

Well-Known Member
Licensed User
Longtime User
since this morning i'm having this error
B4X:
** Activity (main) Create, isFirst = true **


** Activity (main) Pause, UserClosed = false **


java.lang.NullPointerException


    at de.donmanfred.b4a.MariaDB.CloseDatabase(MariaDB.java:860)
    at com.first.mysqlmariadb.main._activity_pause(main.java:370)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at com.first.mysqlmariadb.main.onPause(main.java:260)
    at android.app.Activity.performPause(Activity.java:4568)
    at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1199)
    at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2707)
    at android.app.ActivityThread.performPauseActivity(ActivityThread.java:2676)
    at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:2654)
    at android.app.ActivityThread.access$800(ActivityThread.java:128)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1168)
    at android.os.Handler.dispatchMessage(Handler.java:99)


    at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:198)
    at anywheresoftware.b4a.Msgbox.msgbox(Msgbox.java:137)
    at anywheresoftware.b4a.keywords.Common.Msgbox2(Common.java:438)
    at anywheresoftware.b4a.keywords.Common.Msgbox(Common.java:404)
    at com.simplysoftware.mysqlmariadb.main._activity_create(main.java:334)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at com.first.mysqlmariadb.main.afterFirstLayout(main.java:100)
    at com.first.mysqlmariadb.main.access$100(main.java:17)
    at com.first.mysqlmariadb.main$WaitForLayout.run(main.java:78)
    at android.os.Handler.handleCallback(Handler.java:605)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4517)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
Is there a possibility that you are trying to close the database before it has been initialising?
 

macerau

Member
Licensed User
Longtime User
Thanks @DonManfred. I am will give it a shot and let you know. If not I can just get you a connection to my test DB and you can play with it there.

Thanks again!
Please help me,
your sample program does not work !
Error compiling program.

Error description: Missing parameter.
Occurred on line: 41
db.ExecuteBatchASync(batch)
Word: )
 

DonManfred

Expert
Licensed User
Longtime User
Error compiling program
change
B4X:
db.ExecuteBatchASync(batch)
to
B4X:
db.ExecuteBatchASync(batch,"taskname")

From the documentation
ExecuteBatchASync (batch As List, Task As String)
executes a batch of SQL-Commands (insert, update, delete)

The library has changed after i created the Example
 

wonder

Expert
Licensed User
Longtime User
@DonManfred

Your library was finally put to good use today.
I've started to work on a small project which requires remote database access and I have to say that it works like a charm!
Really intuitive and fast! Congratulations on your work! :)
 

wonder

Expert
Licensed User
Longtime User
I'm sorry for the "noob" question.

I have a database "mytables.db" in File.DirDefaultExternal.
Which url should I use?

- File.DirDefaultExternal & "mytables.db" ?
- 127.0.0.1/mytables.db ?

B4X:
Sub Process_Globals
    Dim db_host = ??????? As String
    Dim db_name = ??????? As String
    Dim db_user = "master" As String 
    Dim db_pass = "12345" As String
End Sub

Sub Activity_Create(FirstTime As Boolean)
     DB.Initialize("DB", db_host, db_user, db_pass, db_name)
End Sub

pls halp mi...
 

Peter Simpson

Expert
Licensed User
Longtime User
Hello @wonder, I've got to keep this short and sweet as I'm just about to walk into a meeting with a client who needs some bespoke software developing.
I believe that you have gotten SQLite and MySQL mixed up. mytables.db is an SQLite database, where as
DB.Initialize("DB", db_host, db_user, db_pass, db_name) is for an MySQL database, not unless you are synchronising 2 different databases.

I'll try to answer your follow up question asap...
 

wonder

Expert
Licensed User
Longtime User
First of all, I'm sorry for the confusion. Until 3 months ago, all I knew about databases was that something called "MS Access" and "mySQL" exists. I'm pretty new to this world.
I created a database with SQLite Expert on my PC (thanks Peter!) and I want to use it locally (in File.DirDefaultExternal) to read/write settings in my game.

Do you have an MYSQL-Server running on the device????
No, I don't... Just the database file.

Hello @wonder, I've got to keep this short and sweet as I'm just about to walk into a meeting with a client who needs some bespoke software developing.
I believe that you have gotten SQLite and MySQL mixed up. mytables.db is an SQLite database, where as
DB.Initialize("DB", db_host, db_user, db_pass, db_name) is for an MySQL database, not unless you are synchronising 2 different databases.

I'll try to answer your follow up question asap...
Thanks! I think I'm starting to understand the differences... So I need DBUtils instead?
 

Tom Law

Active Member
Licensed User
Longtime User
My app is now running well with your connector and the speed is extremely good, however I have one small problem. When I change the orientation of the tablet I lose the connection and it doesn't reconnect. Could you suggest the best way to solve this.
 

Tom Law

Active Member
Licensed User
Longtime User
Yes I had done that but for some reason it hasn't reconnected, do I perhaps need to reinitialise the connector?
 
Top