将MySQL Azure与Java连接 [英] Connecting MySQL Azure with Java
本文介绍了将MySQL Azure与Java连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我面临着使用Java连接到Azure MySQL数据库的问题.虽然每当我使用MySQL工作台连接同一数据库时,连接都会按预期工作.
I am facing an issue to connect to azure MySQL database with Java. Though whenever I am connecting with same database with MySQL workbench the connection working as expected.
要进行连接,我尝试使用下面提到的两个url字符串的代码.
To connect the same I tried below codes where used both of the url string mentioned.
Class.forName("com.mysql.jdbc.Driver");
// String url = "jdbc:mysql://***-mysqldbserver.mysql.database.azure.com:3306/medilegaldb?autoReconnect=true";
String url ="jdbc:mysql://***-mysqldbserver.mysql.database.azure.com:3306/medilegaldb?useSSL=true&requireSSL=false";
Connection con = DriverManager.getConnection(url, "user", "pass");
需要帮助来确定问题.
推荐答案
您使用了哪个版本的MySQL-connector-java?我使用5.1.6并遇到了相同的错误.但是,如果我使用5.1.31,它可以工作.请让我知道是否可以解决您的问题.
Which version of MySQL-connector-java did you use? I used 5.1.6 and encountered the same error. But if I use 5.1.31, it works. Please let me know if this fix your issue.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.31</version>
</dependency>
这篇关于将MySQL Azure与Java连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文