当前位置:网站首页>Solutions to SSL and time zone errors when using JDBC to operate the database
Solutions to SSL and time zone errors when using JDBC to operate the database
2022-07-18 08:24:00 【Java Genie】
Start with my code :
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Test {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
String url="jdbc:mysql://localhost:3306/tsingby";// My database is tsingby
String user="root";
String password="root";
Class.forName("com.mysql.cj.jdbc.Driver");
Connection connection = DriverManager.getConnection(url, user, password);
System.out.println(connection);
connection.close();
}
}
Say my question again : stay Java use JDBC operation MySql8.0 The following exception occurred during database
Exception in thread "main" 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.
It means :
The time zone value of the server does not recognize or represent multiple time zones . If you want to use time zone support , You must configure the server or JDBC The driver ( adopt serverTimezone Configuration properties ).
At this time 8 Add two parameters to the row , Namely serverTimezone and useSSL, Like this .
String url="jdbc:mysql://localhost:3306/tsingby?serverTimezone=GMT%2B8&useSSL=false";
The modified code :
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Test {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
String url="jdbc:mysql://localhost:3306/tsingby?serverTimezone=GMT%2B8&useSSL=false";
String user="root";
String password="root";
Class.forName("com.mysql.cj.jdbc.Driver");
Connection connection = DriverManager.getConnection(url, user, password);
System.out.println(connection);
connection.close();
}
}
At this point, it can run perfectly , Print out connection The address of the
边栏推荐
- fftshift有什么用?MATLAB做FFT后为什么还要fftshift?
- 676.实现一个魔法字典·前缀树
- Li Mu hands on deep learning V2 anchor box and code implementation in target detection
- 安徽大学标志性建筑
- Difference between shape parameter and scale parameter in probability density function
- Face beating
- 家居建材企业如何打造智慧供应链管理体系?数商云供应链系统深耕采购、物流多业务应用场景
- Usage analysis of [:, none] in pytoch
- Software architecture and design (VI) -- hierarchy
- 开发那些事儿:如何解决RK芯片视频处理编解码耗时很长的问题?
猜你喜欢

5 practices of ITSM to ensure the agility of IT service desk

J9 Digital Science Popularization: Web3.0 is far away? No, it's already here

Difference between shape parameter and scale parameter in probability density function

薄膜铜箔导电电位测量

One question per day · 648 Word replacement · prefix tree

Face beating

每日一题·1252.奇数值单元格的数目·模拟优化

From March to June, after summary, more than 200 pages of true question notes and detailed explanations (including core test sites and 6 major factories)

Torch in pytoch Sort() and torch Argsort() function parsing

概率密度函数中形状参数和尺度参数的区别
随机推荐
Matlab深度学习实践之手写体识别(含详细注释)
Handwriting recognition in MATLAB deep learning practice (including detailed notes)
Matlab求正态函数积分,积分对应的分位点
Race · 6116 · calculate the value of Boolean binary tree · recursion
Meituan side: @transactional principle and common pits?
使用POI替换word中的特定字符/文字改进版
Is it safe for Huatai Securities to open an account? How to open an account?
Matlab:数据集读取 imageDatastore() 的用法
Matlab: exchange two rows (columns) of the matrix
347. The first k high-frequency elements Structure array sorting
If the scheduled task is based on the framework
If in SQL determines the error
Matlab: usage of reading imagedatastore() from dataset
Unity IoTAR物联网增强现实教程
Matlab:交换矩阵的两行(列)
8254 定时/计数器应用实验
Matlab:拆分数据集 splitEachLabel() 的用法
Is it true or false that blue collar workers are sleepy and live broadcasting is needed?
CTSI 基金会储备透明度报告——2022 年 7 月
Meituan side: why does thread crash not cause JVM crash?