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

MarcoRome

Expert
Licensed User
Longtime User
Hi Don. One question... i try your library + HtppUtils2 + okHttp ( i connect with server that give me Json , and connect MySql with your great library ).
But when i compile i have error ( seem incompatible ). Do you have tried this ??
Thank you
 

MarcoRome

Expert
Licensed User
Longtime User
Right Don. im out now and so i can send this evening. But anyway i think ( maybe wrong ) that if you add in empty project only library MSMsql + HtppUtils2 + okHttp, you already have this error in compilation.
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Main")
    '             Event  Database Host          Username   Password           Databasename
    'db.Initialize("sql","host.com","dbuser","dbpassword","database")
  
    ' Manfred
    db.Initialize("MySQL","host","user","password","database")
    db.ListTablesAsync
    Dim j As HttpJob
    j.Initialize("JobName",Me)
    j.Download("http://snapshots.basic4android.de")
End Sub
Sub Activity_Resume
    Log("Activity_Resume()")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub MySQL_ExecResult(meta As Map)
    Log(meta)  
End Sub
Sub MySQL_Status(Connected As Boolean, ReConnecting As Boolean, RetriesLeft As Int)
    Log($"MySQL_Status(${Connected},${ReConnecting},${RetriesLeft})"$)
End Sub
Sub MySQL_ListTables(tables As List, ms As Long)
    Log($"MySQL_ListTables(${tables},${ms} ms)"$)
End Sub
Sub JobDone(Job As HttpJob)
  Log("JobDone("&Job.JobName&")")
  ProgressDialogHide
    If Job.Success Then
      'Dim res As String = Job.GetString
    'Log("Server response: " & res)
  Else
    ToastMessageShow("Error: " & Job.ErrorMessage,True)
  End If
    Job.Release         
End Sub


Works!
 

MarcoRome

Expert
Licensed User
Longtime User
Mhhh... ok i send you code this evening . Thank you for now
 

MarcoRome

Expert
Licensed User
Longtime User

you are right Don. The problem is another. Thank you anyway
 

DonManfred

Expert
Licensed User
Longtime User
Thanks anyway
you cn easily use the jSQL library to connect to a remote db with b4j
B4X:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Dim sql1 As SQL

End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UNIFIED")
    'MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
    sql1.InitializeAsync("sql1", "com.mysql.jdbc.Driver", "jdbc:mysql://hostname/dbname?characterEncoding=utf8", "username", "dbpassword")

    MainForm.Show
End Sub

Sub sql1_Ready (Success As Boolean)
   Log(Success)
   If Success = False Then
     Log(LastException)
     Return
   End If
   Dim rs As ResultSet = sql1.ExecQuery("SELECT table_name FROM information_schema.tables")
   Do While rs.NextRow
     Log(rs.GetString2(0))
   Loop
   rs.Close
End Sub
 

samperizal

Active Member
Licensed User
Longtime User
Regards.
Using this code
db.PReparedStatement ("Update New Customers Set Image = Code = Where ?;")
db.SetPeparedBlob (1 File.Combine (File.DirRootExternal, "PeopeWorksTemp.jpg"))
db.SetPeparedString (2, c.GetString ("Code"))
db.ExecutePeparedStatement

Error occurred on line: 1289 (Sincronizar)
java.sql.SQLException: Error reading from InputStream java.io.IOException
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:996)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:935)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:924)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:870)
at com.mysql.jdbc.PreparedStatement.readblock(PreparedStatement.java:2740)
at com.mysql.jdbc.PreparedStatement.streamToBytes(PreparedStatement.java:4557)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2266)
at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2191)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1165)
at de.donmanfred.b4a.MySQL.ExecutePeparedStatement(MySQL.java:297)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:712)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:244)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:132)
at de.amberhome.quickaction.QuickAction$2.onItemClick(QuickAction.java:143)
at de.amberhome.quickaction.QuickAction$4.onClick(QuickAction.java:268)
at android.view.View.performClick(View.java:4442)
at android.view.View$PerformClick.run(View.java:18473)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
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:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.io.IOException: read failed: EBADF (Bad file number)
at libcore.io.IoBridge.read(IoBridge.java:484)
at java.io.FileInputStream.read(FileInputStream.java:179)
at com.mysql.jdbc.PreparedStatement.readblock(PreparedStatement.java:2738)
... 26 more
Caused by: libcore.io.ErrnoException: read failed: EBADF (Bad file number)
at libcore.io.Posix.readBytes(Native Method)
at libcore.io.Posix.read(Posix.java:128)
at libcore.io.BlockGuardOs.read(BlockGuardOs.java:149)
at libcore.io.IoBridge.read(IoBridge.java:474)


the following error occurs
 

walterf25

Expert
Licensed User
Longtime User
Yes it's the flexi table Class.
Note that this not part of this library.
Thanks jahswani, yes i know, i'm just asking because i like how it looks.

Walter
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Sub Create_Table
    TblInvList.Initialize(Me, "TblInvList", 5, Gravity.CENTER_HORIZONTAL, True)
    TblInvList.AddToActivity(PnlTable, 0dip, 0dip, PnlTable.Width, PnlTable.Height)
  
    TblInvList.SetHeader(Array As String("Name", "Continent", "Region", "Population", "Local Name"))
    TblInvList.SetColumnsWidths(Array As Int(20%x, 20%x, 20%x, 12%x, 28%x))          
    TblInvList.SetCellAlignments(Array As Int (Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.RIGHT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL)))
End Sub

Sub Populate_Table
    If ResultList.IsInitialized = False Then
        Msgbox("Records Not Found", "Warning")
    Else
        TblInvList.ClearAll
'Log(ResultList)
        Dim Row As String
        For I = 0 To ResultList.Size - 1
'Log(Row)      
            Row = ResultList.Get(I)
            TblInvList.AddRow(Regex.Split(",", Row.Replace("[","").Replace("]","")))
        Next
    End If
End Sub

Sub TblInvList_CellClick (Col As Int, Row As Int)
    ActionBar.Subtitle = TblInvList.GetValue(Col, Row)
End Sub

Sub TblInvList_CellLongClick (Col As Int, Row As Int)
    ActionBar.Subtitle = TblInvList.GetValue(Col, Row)
End Sub

B4X:
Sub MySQL_QueryResult(data As List, meta As Map)
    ResultList = data
    ToastMessageShow(meta.Get("RecordCount") & " rows retrieved in " & meta.Get("ms") & " milliseconds", True)
    CallSub(Null, Populate_Table)

'    For i = 0 To data.Size - 1
'        Log(data.Get(i))
'    Next
'    Log(data.Size)  
'    Log("Meta = " & meta.Size)  
End Sub

PS: You are reffering to an example @Peter Simpson wrote and send to me.
 

adastra

Member
Licensed User
Longtime User
main_globals (java line: 470)
java.lang.VerifyError: de.donmanfred.b4a.MySQL
at b4a.example.main._globals(main.java:470)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at b4a.example.main.initializeGlobals(main.java:306)
at b4a.example.main.afterFirstLayout(main.java:97)
at b4a.example.main.access$100(main.java:17)
at b4a.example.main$WaitForLayout.run(main.java:78)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
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)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

hi i am using your sample which i got from your sendbox. it is showing error.
i am using b4a version 5.02(1). some time back i have used this library in my code .
but now this time it is showing error. please help
 
Last edited:

adastra

Member
Licensed User
Longtime User
i am using your sample code. attaching please check
 

Attachments

  • MySQLExample.zip
    6.7 KB · Views: 213
Cookies are required to use this site. You must accept them to continue using the site. Learn more…