2

Goal: "install" JDBC drivers for MATLAB to use

This article indicated that one can put the JDBC driver .jar file in:

/Library/Java/Extensions/

.bashrc and .bashrc_profile were configured with CLASSPATH

export CLASSPATH="/Library/Java/Extensions/"

Command Line tests:

Users-MacBook-Air:~ user$ ls -l $CLASSPATH
total 3936
-rw-r--r--@ 1 user  wheel  1004840 Feb 26 13:28 mysql-connector-java-5.1.46-bin.jar
-rw-r--r--@ 1 user  wheel  1004838 Feb 26 13:28 mysql-connector-java-5.1.46.jar
Users-MacBook-Air:~ user$ echo $CLASSPATH
/Library/Java/Extensions/

Questions

  • Is there any other steps I need to perform to install the JDBC driver?
  • How can I test from the command line that JAVA can 'see' the JDBC driver?
  • Is it enough to have the .jar files on MATLAB's javaclasspath?

SYMPTOM

MATLAB is unable to open up a database connection to MySQL because no suitable driver found. Ideally, there would be a test to confirm that the issue is in MATLAB and that the JDBC component is properly installed.

UPDATE

Added JDBC driver path to MATLAB's javaclasspath:

>> javaclasspath('-static')
        STATIC JAVA PATH
    /Library/Java/Extensions/
>> ls -l /Library/Java/Extensions/
total 3936
-rw-r--r--@ 1 user  wheel  1004840 Feb 26 13:28 mysql-connector-java-5.1.46-bin.jar
-rw-r--r--@ 1 user  wheel  1004838 Feb 26 13:28 mysql-connector-java-5.1.46.jar
  • Is something not working? – Allan Apr 14 '18 at 1:55
  • @Allan Yes: MATLAB is unable to open up a database connection to MySQL because 'no suitable driver found'. – gatorback Apr 14 '18 at 2:35
  • 1
    Matias is a guide program and so it does not matter what us in your bash files or what any environmental variable is. What do the mailbox manuals suggest? – user151019 Apr 14 '18 at 8:44
1

MATLAB requires the directory and filename be added to the javaclasspath. Litmus test:

>> javaclasspath('-static')
        STATIC JAVA PATH
/Library/Java/Extensions/mysql-connector-java-5.1.46-bin.jar                                               
/Library/Java/Extensions/mysql-connector-java-5.1.46.jar  

Instructions for adding the .jar files to the class path:

  • Run the prefdir command in the Command Window. The output of this command is a file path to the MATLAB® preferences folder on your computer.
  • Close MATLAB.
  • Navigate to the folder from step 1, and create a file named javaclasspath.txt in the folder.
  • Open javaclasspath.txt. Add the full path to the database driver JAR file in javaclasspath.txt. The full path includes the path to the folder where you downloaded the JAR file from the database provider followed by the JAR file name. The following is an example of the path:

    • /home/user/DB_Drivers/mysql-connector-java-5.1.17-bin.jar.
  • Save and close javaclasspath.txt.

  • Restart MATLAB.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .