Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect MySQL to MATLAB?

Tags:

mysql

matlab

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.

like image 216
santosh Avatar asked Feb 03 '23 11:02

santosh


1 Answers

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);
like image 188
Marek Kurdej Avatar answered Feb 05 '23 10:02

Marek Kurdej