I would like to know how to connect a MySQL database to MATLAB software. I downloaded the jdbc connector but I\'m not getting how to specify the path.
http://desk.stinkpot.org:8080/tricks/index.php/2006/02/how-to-get-matlab-to-talk-to-mysql/
Let me quote:
open the classpath.txt file in [matlab path]/toolbox/local/ and add the following line to it (you can download jar file from http://dev.mysql.com/downloads/connector/j/, and after extract you can move it to under the folder : /usr/share/java)
[path to unzipped jdbc driver package]/mysql-connector-java-3.1.12-bin.jar
create a database in mysql (can look up here how to do that)
to connect to the database you’ve created (call it “foo”), type into matlab:
>> conn = database(‘foo’,’[your user name]‘,”,’com.mysql.jdbc.Driver’,'jdbc:mysql://localhost:3306/foo’)
I suppose here that you have created a database called 'mybase' and you use 'root' user without password (don't do that in real life).
You have to remember to add the mysql connector jar file path to java classpath. You can do this by either adding the path to classpath.txt (\toolbox\local) or by using javaclasspath
command directly from Matlab.
You can establish your connection like this:
dbname = 'mybase';
username = 'root';
password = '';
driver = 'com.mysql.jdbc.Driver';
dburl = ['jdbc:mysql://localhost:3306/' dbname];
javaclasspath('path-to-mysql-connector\mysql-connector-java-VERSION-bin.jar');
conn = database(dbname, username, password, driver, dburl);