MySQL connection using SQLDatabaseMBS

  1. 6 months ago

    David C

    23 Nov 2018 Pre-Release Testers, Xojo Pro Derby, ITM

    I have been able to connect to MySQL databases via SQLDatabaseMBS on macOS for years, but it is failing on my latest application.

    I don't know if it's because of my upgrading to Mojave, within SQLDatabaseMBS or my host MySQL (v5.7.24), so I loaded Christian's example below, put in my data and tried it, but it still fails to connect. I can connect using another tool (Sequel Pro), so I know it is possible.

    I have tried my usual 64-bit 'libmysqlclient.20.dylib', the older 32-bit ''libmysqlclient.18.dylib' and the new 'libmysqlclient.21.dylib', but none connect. I have also tried installing the latest mysql Server 8.0.13 and connect to it's included library, but it still will not connect.

    Any clues?

    Dim db As New SQLDatabaseMBS
    Dim f As FolderItem = GetFolderItem("/usr/local/mysql-8.0.13-macos10.14-x86_64/lib/libmysqlclient.21.dylib", FolderItem.PathTypeShell)
    
    // where is the library?
    // you can place the database client library files where you want.
    // example code just has some convenient location for testing.
    
    'db.SetFileOption SQLConnectionMBS.kOptionLibraryMySQL, SpecialFolder.UserHome.Child("libmysqlclient.dylib")
    'db.SetFileOption SQLConnectionMBS.kOptionLibraryMySQL, SpecialFolder.Desktop.Child("libmysqlclient.20.dylib")
    'db.SetFileOption SQLConnectionMBS.kOptionLibraryMySQL, SpecialFolder.Desktop.Child("libmysqlclient.21.dylib")
    db.SetFileOption SQLConnectionMBS.kOptionLibraryMySQL, f
    
    // connect to database
    // in this example it is Oracle,
    // but can also be Sybase, Informix, DB2
    // SQLServer, InterBase, SQLBase and ODBC
    
    db.DatabaseName="mysql:mysql.MyAppName.com,3306@myDatabase"
    db.UserName="myUserName"
    db.Password="myPassword"
    
    If db.Connect Then
    
    MsgBox "We are connected!"
    
    dim con as SQLConnectionMBS = db.Connection 
    MsgBox "Server Version: "+con.ServerVersionString
    
    // Disconnect is optional
    // autodisconnect will ocur in destructor if needed
    
    else
    MsgBox db.ErrorMessage
    end if
    
    db.Close

    MySQL gives the error:

    dlopen(libmysqlclient_r.dylib, 1): image not found
    dlopen(libmysqlclient_r.15.dylib, 1): image not found
    dlopen(libmysqlclient_r.16.dylib, 1): image not found
    dlopen(libmysqlclient_r.18.dylib, 1): image not found
    dlopen(libmysqlclient.dylib, 1): image not found
    dlopen(libmariadb.dylib, 1): image not found
    
    DBMS API Library loading fails
    This library is a part of DBMS client installation, not SQLAPI++
    Make sure DBMS client is installed and
    this required library is available for dynamic loading

    I found a typo in mysql.cpp here, so it looks like the last SQLAPI update brought that.

    I'll rebuild you a new copy of the plugin.

  2. Christian S

    23 Nov 2018 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    before passing in a file path, you could check with exists on the folderitem whether the file is there.

    You may be looking in the wrong folder.

  3. David C

    23 Nov 2018 Pre-Release Testers, Xojo Pro Derby, ITM

    Yes, I had copied the file to the correct locations and verified that they were correct.

  4. Christian S

    23 Nov 2018 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    this is strange, especially as the error message above have no paths!?

  5. Christian S

    23 Nov 2018 Pre-Release Testers, Xojo Pro, XDC Speakers Answer Germany

    I found a typo in mysql.cpp here, so it looks like the last SQLAPI update brought that.

    I'll rebuild you a new copy of the plugin.

  6. Christian S

    23 Nov 2018 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    The link:
    https://www.dropbox.com/sh/ifcgf745zm0g5p6/AAD7APgbyStTWx2ZOC9-YKSwa?dl=0

  7. Christian S

    23 Nov 2018 Pre-Release Testers, Xojo Pro, XDC Speakers Germany

    and finally uploaded.

  8. David C

    25 Nov 2018 Pre-Release Testers, Xojo Pro Derby, ITM

    Working again!

or Sign Up to reply!