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
Best Answer
MATLAB requires the directory and filename be added to the javaclasspath. Litmus test:
Instructions for adding the .jar files to the class path:
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:
Save and close javaclasspath.txt.