[Chargeable] MSMariaDB - Another connector to MySQL

DonManfred

Expert
Licensed User
Longtime User
You can send a small sql query to get a ninimum of data... If the connection is lost it will reconnect in such case. But this usually can take a few seconds till the connection is rebuild.

Reinitializing the connector should be useable too. Did not tried this but it should work.
 

Tom Law

Active Member
Licensed User
Longtime User
The initialisation is done under the if firsttime routine under Sub Activity_Create(FirstTime AsBoolean).

If FirstTime Then
MYSQL.Initialize ("MYSQL","my site URL","username","password","database name")
MYSQL.EnableReconnect
MYSQL.check_connection
MYSQL.ReconnectTime = 1
EndIf

Would you suggest bringing it out from inside the FirstTime condition.
 

Tom Law

Active Member
Licensed User
Longtime User
Main Screen.png
Well my application is finally finished and its performing well. It is a program for field service engineers in the fire industry and details of jobs are sent to and from an office via an online MySQL database. I had previously built this using httputils and it would upload a number of jobs in about 25 seconds. Indeed it had a sequence of dialog boxes to inform the operator which table was uploading or downloading. There are a total of 10 tables, 5 are MySQL and 5 are used by the Sqlite database on the tablet.The application is now so fast that my dialogs do not have time to appear on screen and they have been removed. Many thanks to Manfred for his connector, its extremely fast. I would recommend anyone considering using httputils(2) to consider this connector instead.
 

Prosg

Active Member
Licensed User
Longtime User
Hello

if i have 2 query like :
db.QueryASync("SELECT post_date, post_status FROM am_posts where id = " & numeroFacture"")
db.QueryASync("SELECT client_name, client_adress FROM am_client where clientid = " & clientId "")

How can i have cursor for this ?


lblDate.txt = data.Get("post_date")
lblStatus.txt = data.Get("post_status")
...

the 2 result must be in Sub MySQL_QueryResult(data As List, meta As Map) ???

but how ? do u have an example ?

ty
 

DonManfred

Expert
Licensed User
Longtime User
How can i have cursor for this ?
The Library does not provide a "CURSOR"... You need to use the data (List of Maps) in the result-sub

B4X:
Sub MySQL_QueryResult(data As List, meta As Map) 'Twice
    For i = 0 To data.Size - 1
        Log(data.Get(i))
        Dim dataset As Map = data.Get(i)
        LogColor("===============",Colors.Blue)
        For o = 0 To dataset.Size -1
            Log(dataset.GetKeyAt(o)&" = "&dataset.GetValueAt(o))
        Next
    Next
    Log(data.Size)   
    Log(meta.Size)   
End Sub
 

jzfla01

Member
Licensed User
Longtime User
I was wondering if the MySQL library could be used to access a Paid Shared hosting domain MYSQL database. For example, I can use PHP to connect to the database, but was wondering if I could access the DB using the library and an IP address? The hosting site is inMotion Hosting.

Thanks.
 

DonManfred

Expert
Licensed User
Longtime User
Is there a way to change the port?
Have you tried to change

B4X:
db.Initialize("eventname","mydbdomain.com","dbusername","dbpassword","dbname")
to
B4X:
db.Initialize("eventname","mydbdomain.com:1234","dbusername","dbpassword","dbname")
to change the port to 1234?
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
One more stupid question.... :eek:

If there is an error in the SQL I see that the error is sent to the log window but MySQL_ExecResult returns a NULL, How can I log that error to my logs system? Pic included! o_O

upload_2015-8-11_13-23-33.png
 

samperizal

Active Member
Licensed User
Longtime User
Hello

Error with the library [chargeable] MSMySQL



Error occurred on line 151 (Conf_Mysql)
java.lang.ClassNotFoundException: from $ donmanfred $ B4A $ MariaDB
at anywheresoftware.b4a.shell.Shell.getCorrectClassName (Shell.java:544)
at anywheresoftware.b4a.shell.Shell.createObject (Shell.java:516)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl (Shell.java:320)
at anywheresoftware.b4a.shell.Shell.raiseEvent (Shell.java:238)
at java.lang.reflect.Method.invokeNative (Native Method)
at java.lang.reflect.Method.invoke (Method.java:521)
at anywheresoftware.b4a.ShellBA.raiseEvent2 (ShellBA.java:121)
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent (BA.java:171)
anywheresoftware.b4a.objects.ViewWrapper at $ 1.onClick (ViewWrapper.java:78)
at android.view.View.performClick (View.java:2408)
android.view.View at $ PerformClick.run (View.java:8816)
at android.os.Handler.handleCallback (Handler.java:587)
at android.os.Handler.dispatchMessage (Handler.java:92)
at android.os.Looper.loop (Looper.java:123) ~ e: at android.app.ActivityThread.main (ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative (Native Method)
at java.lang.reflect.Method.invoke (Method.java:521)
com.android.internal.os.ZygoteInit at $ MethodAndArgsCaller.run (ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:626)
at dalvik.system.NativeStart.main (Native Method)


Code

Sub test_Click

Dim db As MSMaria
If Edit_Servidor.Text = "" Or Edit_Usuario.Text = "" Or Edit_Datos.Text = "" Or Edit_Clave.Text = "" Then
Msgbox ("missing fields to be completed", "Error")
Else
Try
str_sql = "Select * from Server"
c = Main.sql_conexion.ExecQuery (str_sql)
If c.RowCount = 0 Then
Msgbox ("No server is configured", "Error")
Else
c.Position = 0
db.Initialize("MySQL",c.GetString("Servidor"),c.GetString("Usuario"),c.GetString("Clave"),c.GetString("Datos"))
MsgBox ("Connection", "")

End If

Catch
ToastMessageShow ("Error when checking", True)
Activity.Finish
End Try


End If
End Sub


Dim db As error MSMaria


Thank You
 
Top