解决Connections could not be acquired from the underlying database!问题
搭建自定义持久层框架出现的问题
解决方案:
- 驱动配置有误:driver=com.mysql.cj.jdbc.Driver
在mysql8.0.xx的版本中需要在驱动配置中添加cj - 数据库连接地址有误:url=jdbc:mysql://localhost:3306/zdy_mybatis?3useUnicode=true&characterEncoding=utf8
- 密码或帐号有误:username=root password=root
- 数据库服务未启动或无权访问数据库
- mysql依赖引入无效,如果数据库是MySQL5.7等版本使用驱动包也应该是5.xx版本,在项目中使用的数据库是8.0.21则直接引入相对应的mysql-connector-8.0.16.jar包
- 需要在数据库 URL中设置serverTimezone属性:jdbc:mysql://localhost:3306/zdy_mybatis?serverTimezone=GMT%2B8"(就是这个时区属性导致我被困扰了好久QAQ)
错误解决后项目即可运行成功!