X DevAPI的MySQL Connector / J SSL禁用

时间:2018-10-16 08:02:40

标签: java mysql mysql-connector

我正在使用mysql-connector-java 8.0.12通过X DevAPI连接MySQL数据库。我不需要为本地主机设置SSL。如何禁用安全连接?我的Java代码后面是堆栈跟踪。

session = new SessionFactory().getSession("mysqlx://127.0.0.1:33060/world_x?user=root&password=");
System.out.println(session.isOpen());

错误:需要安全连接,但服务器未配置SSL

com.mysql.cj.exceptions.CJCommunicationsException: A secure connection is required but the server is not configured with SSL.
at com.mysql.cj.protocol.x.XProtocol.negotiateSSLConnection(XProtocol.java:159) ~[mysql-connector-java-8.0.12.jar:8.0.12]
at com.mysql.cj.protocol.x.XProtocol.beforeHandshake(XProtocol.java:226) ~[mysql-connector-java-8.0.12.jar:8.0.12]
at com.mysql.cj.protocol.x.XProtocol.connect(XProtocol.java:232) ~[mysql-connector-java-8.0.12.jar:8.0.12]
at com.mysql.cj.MysqlxSession.<init>(MysqlxSession.java:80) ~[mysql-connector-java-8.0.12.jar:8.0.12]
at com.mysql.cj.xdevapi.SessionImpl.<init>(SessionImpl.java:71) ~[mysql-connector-java-8.0.12.jar:8.0.12]
at com.mysql.cj.xdevapi.SessionFactory.getSession(SessionFactory.java:79) ~[mysql-connector-java-8.0.12.jar:8.0.12]

1 个答案:

答案 0 :(得分:1)

我从这个parameter references找到了解决方案。希望回答我的问题可以节省一些时间。更改网址如下

  

mysqlx://127.0.0.1:33060 / world_x? xdevapi.ssl-mode = DISABLED &user = root&password =