问题描述
我想知道如何将MySQL数据库连接到MATLAB软件.我下载了jdbc连接器,但没有得到指定路径的方法.
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.
推荐答案
我在这里假设您已经创建了一个名为"mybase"的数据库,并且您使用了没有密码的"root"用户(在现实生活中不要这样做).
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).
您必须记住将mysql连接器jar文件路径添加到java classpath.您可以通过将路径添加到classpath.txt(\ toolbox \ local)或直接从Matlab使用javaclasspath
命令来实现.
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.
您可以这样建立连接:
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);
这篇关于将MySQL连接到MATLAB吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!