初次链接JDBC遇到:Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure。

数据库链接失败的原因有以下:URL错误;用户名错误;密码错误。

String url = "jdbc:mysql://localhost:3306/jdbcStudy?useUnicode=true&characterEncoding=utf8&useSSL=true";
String username = "root";
String password = "123456";

我的用户名和密码都正确,将url的安全套接字协议useSSL设置成false。

因为JDBC在mysql进行连接的时候,如果mysql的版本是5.7之后的版本必须要加上useSSL=false,mysql5.7以及之前的版本则不用进行添加useSSL=false,会默认为false,一般情况下都是使用useSSL=false。

解决后:

String url = "jdbc:mysql://localhost:3306/jdbcStudy?useUnicode=true&characterEncoding=utf8&useSSL=false";
String username = "root";
String password = "123456";

JDBC数据库链接:Communications link failure失败相关推荐

  1. mac之idea连接MySQL数据库报com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

    项目场景: 最近入手了一台MacBookPro(谨慎尝试,用惯了windos后使用感具别扭,需要大量时间来适应),下载了最新的idea和最新的mysql8.0.23,然后开始了漫长而艰辛的开始,各种没 ...

  2. Underlying cause: com.mysql.cj.jdbc.exceptions.CommunicationsException : Communications link failure

    Hive试图schematool -dbType mysql -initSchema时候报错如下: Metastore connection URL:     jdbc:mysql://Desktop ...

  3. com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

    com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure 数据库jdbc连接异常,数据库连接异 ...

  4. Druid 连接池 报错 com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

    场景赘述 早晨查看项目前一天的实际运行日志,发现了 一个Springboot项目中的druid 连接池和 mysql 产生了异常信息,重连暂并未对系统产生影响 下面是具体报错信息: com.mysql ...

  5. 连接数据库报错com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure的解决方法

    控制台报错 Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure com. ...

  6. 【Linux 报错】com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The las

    报错信息如下: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failureThe last pa ...

  7. 解决:com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure(真实有效)

    数据库连接失败 在数据库连接失败,经常会有蛮多一系列的问题导致的原因,这个时候一定要多去尝试一下各种方法,并且做好自己的梳理! 一.例如我在SpringBoot项目中使用了阿里的数据库连接池Driud ...

  8. Rejecting re-init Communications link failure

    @[TOC](Rejecting re-init on previously-failed class java.lang.Class<com.mysql.cj.MysqlType>: j ...

  9. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure 数据库报错

    -- 查询mysql 数据库链接空闲时间持有最大空闲时间,单位为秒 SHOW VARIABLES WHERE VAriable_name = 'interactive_timeout'; -- 会出现 ...

最新文章

  1. 在vue中let var 和const 区别
  2. 重整谋定电商经信研究新格局-李玉庭:人工智能精细化运营
  3. Linux设置路由器ip租约时间,入坑Linux-day15(使用DHCP动态管理主机地址)
  4. MySQL / B + 树算法在 mysql 中能存多少行数据?
  5. Jdbc访问mysql查询聚合函数_JDBC连接参数设置对Oracle数据库的影响分析
  6. QPixmap QImage 相互转化
  7. java 获取所有带指定注解的类名_SXT DAY023 反射和注解
  8. [Vo. 1 No. 1] 高等代数一题[Sep. 19, 2013]
  9. UVA1437 String painter
  10. 解密Oracle备份工具-exp/imp
  11. 将矩阵转为一行_理解矩阵乘法
  12. android 加载系统私有库,Android 搭建私有maven仓库及上传项目
  13. matlab 命令集结(1)
  14. Linux 下的任务管理 —— ps、top
  15. 最近学习安卓中总结的一些知识点
  16. 小车手app安卓版下载_美森网校app下载_美森网校安卓版下载[英语培训]
  17. 电脑需要装杀毒软件吗?两个理由看完你做决定
  18. 新浪微博的架构发展历程
  19. JavaScrpit+Html实现日期时间启动、停止操作(应用场景:计时器、秒表)
  20. Objective C 常用代码片段制作(code snippet library)

热门文章

  1. jQuery无法获取【runat=server】服务端控件的解决办法
  2. js校验其他参数(非空、邮箱、url等)
  3. mysql遍历List集合
  4. 面向六部十层电梯群控算法的研究
  5. 仓储管理|呆滞物料产生的原因及改善措施
  6. Android模拟器实现人脸智能跟踪识别
  7. android frp分区,android系统的分区结构
  8. QT 设置滚动条样式
  9. 百练 2786 Pell数列
  10. BurpSuite Proxy 给代理设置上层代理