将MySQL连接到MATLAB吗? [英] Connect MySQL to MATLAB?

查看:94
本文介绍了将MySQL连接到MATLAB吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何将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吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆