问题描述
我正在使用端口 1433 在 docker 上运行 MSSQL:
并且能够连接到它并使用我从互联网下载的简单工具 (SQLDbx) 进行查询:
但是,当我尝试通过此代码使用 JDBC 进行连接时:
public static void main(String[] args) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:1433/SocialDB/","myUsername","myPW");
con.close();
} catch (Exception e) {
System.out.println(e);
}
}
我明白了:
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
我想知道在 docker 上运行 SQLServer 时是否需要执行一些我遗漏的额外步骤,如果没有,我想知道是什么导致了问题。 提前致谢。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)