springboot中数据库的连接
2024-09-03 08:13:27
mysql5.0
1、#mysql数据库连接
2、spring.datasource.driver-class-name=com.mysql.jdbc.Driver
3、spring.datasource.url=jdbc:mysql://localhost:3306xxxx
4、spring.datasource.username=root
5、spring.datasource.password=123456
mysql8.0
1、spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
2、spring.datasource.url=jdbc:mysql://localhost:3306/xxxx?serverTimezone=GMT%2B8
3、spring.datasource.username=root
4、spring.datasource.password=123456
注意:
1、这里的 url 使用了 ?serverTimezone=GMT%2B8 后缀,因为Spring Boot 2.1 集成了 8.0版本的jdbc驱动,这个版本的 jdbc 驱动需要添加这个后缀,否则运行测试用例报告如下错误:
java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more
2、这里的 driver-class-name 使用了 com.mysql.cj.jdbc.Driver ,在 jdbc 8 中 建议使用这个驱动,之前的 com.mysql.jdbc.Driver 已经被废弃,否则运行测试用例的时候会有 WARN 信息
最新文章
- Android版本与api Level
- [.net 面向对象程序设计进阶] (19) 异步(Asynchronous) 使用异步创建快速响应和可伸缩性的应用程序
- Linux下apache+phppgadmin安装配置
- 《oracle每日一练》oracle截取字符的函数
- MFC 中控件的启用与禁用
- Thread的六种状态
- How can I work smarter, not just harder? Ask it forever
- Hadoop on Mac with IntelliJ IDEA - 1 解决input path does not exist问题
- DOM事件逐层上机传递
- QT5新手上路(1)安装
- Graham算法—二维点集VC++实现
- codeforces 609F. Frogs and mosquitoes 二分+线段树
- 三、nginx301跳转302跳转
- 7.数据本地化CCString,CCArray,CCDictionary,tinyxml2,写入UserDefault.xml文件,操作xml,解析xml
- Java 判断回文字符串有多少和其中的最大字符串
- HashSet集合
- 机器学习 —— 类不平衡问题与SMOTE过采样算法
- HDU 6113 度度熊的01世界
- PHP Session 常用的函数
- 从壹开始前后端分离 [ Vue2.0+.NET Core2.1] 十四 ║ VUE 计划书 &; 我的前后端开发简史