If you try to connect to a local MySQL database based on the Matlab documentation on the database function (see connection example here), you are likely to get the 'Unable to find JDBC driver' error.
To fix the error, first download the JDBC driver from MySQL website.
Once download, unzip and find the mysql-connector-java-5.0.8-bin.jar (or more current version) file and move it to Matlab's java path ($matlabroot\java\jar\).
Now if you type javalclasspath, you should see the jar file appear at the bottom of the static path.
Finally, to test out if everything works as expected, run
conn = database('mysql', 'root', 'DB_password', 'com.mysql.jdbc.Driver', 'jdbc:mysql://localhost/');
conn
tables(conn)
close(conn);
* May need to adjust database name, user account, password, driver name, and url of the database.
worked perfectly, thanks!
ReplyDelete