In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces how to connect the mysql-connector-java driver, the article is very detailed, has a certain reference value, interested friends must read it!
Mysql-connector-java connection driver issu
The driver in mysql-connector-java 5 is com.mysql.jdbc.Driver
The driver in mysql-connector-java 6 is com.mysql.cj.jdbc.Driver
1. JDBC connection Mysql5 com.mysql.jdbc.Driver:
DriverClassName=com.mysql.jdbc.Driver url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&useSSL=false
2. When JDBC connects to Mysql6 com.mysql.cj.jdbc.Driver, you need to specify the time zone serverTimezone:
DriverClassName=com.mysql.cj.jdbc.Driver url=jdbc:mysql://localhost:3306/test?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&useSSL=false
When setting the time zone, if you set serverTimezone=UTC, it will be 8 hours earlier than China time, if in China
You can choose Asia/Shanghai or Asia/Hongkong, for example: driverClassName=com.mysql.cj.jdbc.Driver url=jdbc:mysql://localhost:3306/test?serverTimezone=Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false
Note:
I. If mysql-connector-java uses more than 6. 0, as follows:
Mysql mysql-connector-java 6.0.6
But if you still use com.mysql.jdbc.Driver for your driver, you will report an error:
Loading class' com.mysql.jdbc.Driver'. This is deprecated. The new driver class is' com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
At this point, you need to change com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver
II, and one more warning:
WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45mm, 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.
It is not recommended to establish a SSL connection without server authentication.
If it is not explicitly set, MySQL version 5.5.45, version 5.6.26 + and 5.7.6 + requires the establishment of a SSL connection by default.
To match applications that do not currently use SSL connections, the verifyServerCertificate property is set to 'false'.
If you do not need to use SSL connections, you need to explicitly disable SSL connections by setting useSSL=false.
If you need to connect with SSL, provide a truststore for server certificate verification and set up useSSL=true.
The above is all the contents of the article "how to connect mysql-connector-java drivers". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.