Connect MySQL database through JDBC with Java summary

Source: Internet
Author: User
Tags ssl connection

Participation website: 1, https://www.cnblogs.com/centor/p/6142775.html

2, 53378755

3, 52292099

First, refer to the above website for download:

MySQL Connection driver: mysql-connector-java-8.0.11.

Add a connection driver package to your project based on the reference website tutorial.

Then the copy of Site 1 code runs after the error occurs.

Loading class ' Com.mysql.jdbc.Driver '. This is deprecated. And

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 is established by default if explicit Opti On isn ' t set.

and the server time zone value '??? Ú±êx?? ±?? is a unrecognized or represents more than one time zone.

I looked it up on the Internet.

First error: This error is better resolved, change the com.mysql.jdbc.Driver to Com.mysql.cj.jdbc.Driver.

Second error: The current version of MySQL requires the use of SSL,

Third error: you need to add a parameter after the URL:

So put: String url = "Jdbc:mysql://localhost:3306/user_password"; Make the following changes:

String url = "Jdbc:mysql://localhost:3306/user_password?servertimezone=utc&usessl=false";

Knowledge Point Supplement:

Connector driver Reference Document: https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference.html

http://elf8848.iteye.com/blog/1684414

Connect MySQL database through JDBC with Java summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.