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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With