[chargeable] MSMySQL - Yet another MySQL-Library (but a FAST one :-))

johnB

Active Member
Licensed User
Longtime User
I got an another error sir. String only without blob.

B4X:
DB.PeparedStatement("INSERT INTO test SET text_ = ?")
        DB.SetPeparedString(1, EditText1.Text)
        DB.ExecutePeparedStatement

Connected to Database
java.sql.SQLException: Can't call commit when autocommit=true

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:878)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:874)
at com.mysql.jdbc.ConnectionImpl.commit(ConnectionImpl.java:1599)
at de.donmanfred.b4a.MySQL.ExecutePeparedStatement(MySQL.java:298)
at ex.escalera.mysql.main._button3_click(main.java:390)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:163)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:77)
at android.view.View.performClick(View.java:4478)
at android.view.View$PerformClick.run(View.java:18698)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)

at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
java.sql.SQLException: Can't call commit when autocommit=true


Hi,
I couldn't find an answer to this, I need to load multiple params during the execution of the app so can't hard code as fixed string values
eg I might need to execute a statement like that given above 100 times while running the app and each time the values to be used in the ? will be different


Thanks in advance
 

DonManfred

Expert
Licensed User
Longtime User
I dont suggest to use Prepared SM for such queries... I suggest to build normal sql queries and just execute them. Maybe in an batch.
 

jahswant

Well-Known Member
Licensed User
Longtime User
Is there a new link to download this library ? It seems like the old one is expired please send me link and credentials ...
 

Lello1964

Well-Known Member
Licensed User
Longtime User
I have a problem with v. 1.09 of msmysql lib.
You are the IP address of mysql server is wrong, i get this error:

An error occurred:
(Line: 0) null
java.lang.Exception: Sub mysql_execresult signature does not match expected signature.
public static anywheresoftware.b4a.pc.RemoteObject Touch.Phone.main_subs_0._mysql_execresult(anywheresoftware.b4a.pc.RemoteObject,anywheresoftware.b4a.pc.RemoteObject) throws java.lang.Exception

if then ip addressi is right, then no problem

this is my sub mysql_ExecResult

Sub mysql_ExecResult( data As List,meta As Map)
Log (meta)
'
End Sub

i think there is a problem in library,

thanks
 

DonManfred

Expert
Licensed User
Longtime User
Is there a new link to download this library ? It seems like the old one is expired please send me link and credentials ...
Please send me an email from the emailadress you donated. Best answer my mail. I´ll send new link.
 

Lello1964

Well-Known Member
Licensed User
Longtime User
I still have problem with MsMysql v 1.09

this is a test with problem

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

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.
    Dim db As MySQL
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("Layout1")
    '             Event  Database Host          Username   Password           Databasename
    db.Initialize("mysql","192.168.2.101","root","admin","touch",True,True)
End Sub
Sub Activity_Resume
    Log("Activity_Resume()")
    db.ListTablesAsync
    db.QueryASync("select * from tavoli ORDER BY numtavolo ASC;" ,"qry1")

    Dim batch As List
    batch.Initialize
    For i=1 To 100
        batch.Add("INSERT INTO tavoli SET numtavolo="&i&";")
    Next
    db.ExecuteBatchASync(batch,"btch")
    db.ExecuteASync("INSERT INTO tavoli SET numtavolo=999;","ins1")
End Sub
Sub MySQL_ExecResult(data As List,meta As Map)
    Log(meta)
End Sub
Sub MySQL_BatchResult(batch As Map  )
    Log(batch)
End Sub
Sub MySQL_QueryResult(data As List, meta As Map)
    'Dim m As Map = meta
    Log("MySQL_QueryResult("&meta&")")
    For i=0 To data.Size-1
        'Log("r:"&data.Get(i))
    Next
End Sub

this is error :

An error occurred:
(Line: 0) End Sub
java.lang.Exception: Sub mysql_batchresult signature does not match expected signature.
public static anywheresoftware.b4a.pc.RemoteObject b4a.example.main_subs_0._mysql_batchresult(anywheresoftware.b4a.pc.RemoteObject) throws java.lang.Exception

error.png

who can tell me why??
 

microbox

Active Member
Licensed User
Longtime User
I'm currently trying JDRC2...but can I use this chargeable MSSQL to connect to several android devices to a database on a windows machine/linux?
 

DonManfred

Expert
Licensed User
Longtime User
I'm currently trying JDRC2
I suggest to hold the RDC2 running. It is the sugegsted way
ut can I use this chargeable MSSQL to connect to several android devices to a database on a windows machine/linux?
If the
- Server is reachable from outside
- and your Database is configured to allow access from everywhere
- and Database is reachable from outside too.

Yes; but you need to have Database-credentials inside your app. It is a security-risk.

You can store the credentials online (jserver for ex.) and get the credentials from your app first using https (okHTTP). After you received the credentials you connect to the database.
 

microbox

Active Member
Licensed User
Longtime User
Thanks for reply DonManfred, I will try to finish my mini project using RDC2 but I might later also want to try your library.
 

johnB

Active Member
Licensed User
Longtime User
Hi

Would be grateful if somebody could give me the parameters for the "Wait For" statement for MSMySQL

My Select statement is - "db1.QueryASync2("SELECT * FROM Dividends WHERE Stock =..............."

Thanks in advance
 

DonManfred

Expert
Licensed User
Longtime User
Would be grateful if somebody could give me the parameters for the "Wait For" statement for MSMySQL
I just tried
B4X:
   db.Initialize("MySQL","xxxxxxxxxxxxxxxxx","xxxxxx","xxxxxxxxxxxx","xxxxxx",True,True) ' MySQL as Eventprefix

    db.QueryASync("select * from Customers LIMIT 0,1 ;", "test1")
    wait for MySQL_QueryResult(data As List, meta As Map)
    Log("MySQL_QueryResult("&meta&")")
    For i=0 To data.Size-1
        'Log("r:"&data.Get(i))
    Next
 

andyr00d

Member
Licensed User
Longtime User
I still have problem with MsMysql v 1.09

this is a test with problem

who can tell me why??

I'm getting the same error from calling a similar function: java.lang.Exception: Sub mysql_execresult signature does not match expected signature.

Can anyone advise on what the correct sub format should be?
 
Last edited:

Andreas_D99

Member
Licensed User
I'm getting the same error from calling a similar function: java.lang.Exception: Sub mysql_execresult signature does not match expected signature.

Can anyone advise on what the correct sub format should be?

I have the same Error, when I resume my App after paused for a longer Time... (several Hours...)
 

Anser

Well-Known Member
Licensed User
Longtime User
I am using this LIB on an app written 1.5 years back. I never had to insert a picture into a BLOB column. But now, I need to modify this app to insert a picture from the phone to a MySQL BLOB column. I understand that, to insert/update a BLOB column without using Base64 encoding etc, I need to rely on the PreparedStatement.

Unfortunately, when I use oCn.ExecutePeparedStatement("MyTaskName"), on the Log I see the following message and my App hangs. The ExecutePeparedStatement is not executed. I see the following on the Log
lib: NOTFOUND 'mydb_onPreparedStatementResult

Here is the code that I use
B4X:
Sub Process_Globals
    Dim oCn As MySQL
End Sub

Sub Service_Create

    Try
        oCn.Initialize("MyDB",cDbIP,cDbUserName,cDbPassword,cDataBase,True,True)
        oCn.EnableReconnect
        Log("Log : Database Connected")
    Catch
        Log("Log : Error could not connect")
    End Try
   
End Sub

Sub ExecPrepStmnt(Parameters As Map)
    Dim cSql As String    = "UPDATE Students SET ProfilePicture = ? WHERE User_ID = ?"

    oCn.PeparedStatement(cSql)
    oCn.setPeparedBlob(1,File.DirDefaultExternal & "/MyProfilePic.jpeg")
    oCn.setPeparedInt(2,2)
    Log("About to execute")
    oCn.ExecutePeparedStatement("MyTaskName")
    Log("executed")
End Sub

Sub MyDB_onPreparedStatementResult(meta As Map)
    LogColor("Inside MyDB_onPreparedStatementResult",Colors.Blue)
    For Each k As String In meta.Keys
        Log(k)
    Next
End Sub

Any guess what could be wrong ?. The MSMySQL Lib version used is 1.09

In Post#29 of this thread (Page 2), you have mentioned about a Java Function to insert image to a BLOB column. Is this already available in this library ?
https://www.b4x.com/android/forum/t...brary-but-a-fast-one.49728/page-2#post-312849
 
Last edited:

Peter Simpson

Expert
Licensed User
Longtime User
Base64 encoding etc
.

This is my MySQL library of choice and I do not have to install anything on to my clients servers and I don't have to interact with my clients database suppliers if online, I've previously wrote why I prefer this solution.

Anyway, I only ever use Base64 for images and ease of use as far as I'm concerned. I personally use the following library to quicky encode and decode Base64 images, that's my personal preference rightly or wrongly. https://www.b4x.com/android/forum/threads/base64-encode-decode-image-library.31031/

Or you could just change to Erels library but that means rewriting everything which I personally wouldn't do as this library is faster when transfering large amounts of data, I've tested them both ;)
 
Last edited:
Top