gpt4 book ai didi

mysql - 在 osX 上设置从 Matlab 到 MySQL 的 JDBC 连接

转载 作者:行者123 更新时间:2023-11-30 22:04:49 27 4
gpt4 key购买 nike

我已经设置了 MATLAB(2016b 64 位)来与本地 MySQL 服务器交互。我按照说明在 Matlab 的 prefdir 位置创建了一个 javaclasspath.txt 文件,我保存了 mysql-connector-java-5.1.40-bin.jar 位置。之后,我使用原生的 Matlab Database Explorer App 建立连接,按照 Matlab 的步骤在当前文件夹中创建了一个 .mat 文件(见图):

enter image description here

如您在上方所见,.mat 文件包含一个带有所列输入的元胞数组。我的问题如下,既然我已经成功设置了服务器,我想创建一个“conn = database()”变量。我怎样才能做到这一点?我读过 Matlab guide还有这个guide在 Stackoverflow 上,但当我 execute 时出现错误“无效连接” :

conn = database('Data_Science', 'root', '*****', 'com.mysql.jdbc.Driver', 'jdbc:mysql://localhost:3306/Data_Science?useSSL=false');


e = exec(conn,['create table BULKTEST (salary decimal, '...
'player varchar(25), signed_date varchar(25), '...
'team varchar(25))']);

我上面的代码有问题吗?我是不是信息写错了?第二部分 (e) 是来自 Matlab 网站的 c/p。所以我怀疑是关于 conn 的。

更新:当我尝试命令 isoprene(conn) 时返回“0”。我仍然不明白为什么我可以通过数据库资源管理器正确连接,但不能通过 conn 命令。

更新:我展示数据库和 Matlab Database Explorer App 的更多照片

enter image description here

enter image description here

enter image description here

最佳答案

好的,问题出在我的代码上,特别是“conn”命令。

当我使用此代码时,不包括 ?useSSL=false :

conn = database('Data_Science', 'root', '*****', 'com.mysql.jdbc.Driver', 'jdbc:mysql://localhost:3306/Data_Science');

我收到了这个警告:

Fri Feb 10 13:48:03 GMT 2017 WARN: Establishing SSL connection without
server's identity verification is not recommended. According to MySQL
5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established
by default if explicit option isn't set. For compliance with existing
applications not using SSL the verifyServerCertificate property is set to
'false'. You need either to explicitly disable SSL by setting useSSL=false,
or set useSSL=true and provide truststore for server certificate verification.

所以我上网查了一下,解决方案是在conn的末尾加上?useSSL=false。事实上,这很有效,因为我不再收到任何进一步的警告,但是当我检查工作区上的连接时,有一行包含以下消息:

The connection property 'useSSL' only accepts values of the form: 'true',
'false', 'yes' or 'no'. The value 'falseData_Science' is not in this set.

这是我以前从未注意到的,事实上这就是导致连接错误的原因。所以我只是反转回原来的 conn,修改我所做的 ?useSSL=false 更改。现在,我仍然收到警告,但它有效。

关于mysql - 在 osX 上设置从 Matlab 到 MySQL 的 JDBC 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42145822/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com