JDBC的坑

小白一枚,今天刚开始用JDBC就遇到问题。
一:java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
两种解决办法:

  1. 将url改为:“jdbc:mysql://localhost:3306/emp?serverTimezone=GMT%2B8”
  2. 在命令行加一句设置失去时区的操作在这里插入图片描述
    二:Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver’. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
    Tue Nov 27 11:34:53 CST 2018 WARN: Establishing SSL connection without server’s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
    针对这个问题网上的解决办法大都是在url后面加一句:useSSL=false,但是我改来改去这个WARN一直都在。有其他办法的朋友欢迎留言。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
MySQL 8.0的JDBC依赖可以通过以下方式进行配置: 1. 首先,你需要在项目的pom.xml文件中添加MySQL的JDBC依赖。可以使用以下代码片段作为参考: ```xml <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.23</version> </dependency> ``` 2. 接下来,你需要在你的Java代码中加载MySQL的驱动类。可以使用以下代码片段作为参考: ```java Class.forName("com.mysql.cj.jdbc.Driver"); ``` 3. 然后,你需要建立与数据库的连接。可以使用以下代码片段作为参考: ```java String url = "jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Hongkong"; String username = "root"; String password = "your_password"; Connection connection = DriverManager.getConnection(url, username, password); ``` 请注意,上述代码中的url参数中包含了一些连接选项,如useUnicode、characterEncoding、useSSL和serverTimezone。这些选项可以根据你的具体需求进行调整。 综上所述,你可以通过添加MySQL的JDBC依赖,加载驱动类,并建立与数据库的连接来配置MySQL 8.0的JDBC依赖。 #### 引用[.reference_title] - *1* *3* [JAVA JDBC使用mysql8.0.jar包连接数据库的小](https://blog.csdn.net/Amluee/article/details/80610286)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [MySQL8.0 的JDBC操作](https://blog.csdn.net/weixin_41066584/article/details/87391226)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值