About using IDEA to connect to mysql error report

About using IDEA to connect to mysql error report

1. Drive issues

If you want to use IDEA to connect to mysql and other databases, you need to download the driver first in IDEA. Generally, when you go to the configured IDEA to connect to the database, IDEA will prompt you that there is no driver installed, and ask whether you need to download it automatically.
Insert picture description here

Here, if you encounter the automatic downloading process, the progress bar is stuck at half of the download, or the download fails directly, you can first import the corresponding package in maven, and then return to the above picture to download the driver again.

Note : Speaking of the maven guide package, there is also a place that is prone to problems. The maven guide jdbc package has an old version and a new version. Here I use the new version 8.0.21.

After guiding the package, you need to configure it
Insert picture description here
Insert picture description here

Then find the package just guided in maven, and add it in.

Note : There is a place to choose Class. Don’t make a mistake, because I am using the new version of 8.0.21. The new version is different from the old version. The difference is that the new version of Class is generally:

com.mysql.cj.jdbc.Driver

The old version is:

com.mysql.jdbc.Driver

If you don’t choose the right one here, you will get an error when you test the connection to the database. By the way, I have used both the old and new versions. I found that the new version starting with 8 is no problem, and the old version starting with 5 is no problem.
Insert picture description here

Then click apply application to

2. Time zone issues

When I first used IDEA to connect to the database, I encountered the problem of time zone mismatch. During the test, IDEA popped up a prompt like this:

Server returns invalid timezone. Go to ‘Advanced’ tab and set ‘serverTimezone’ property manually.

It probably means: the server returned an invalid time zone. Go to the "Advanced" tab and manually set the " serverTimezone " property.

Here we go to the serverTimezone property to set the time zone
Insert picture description here

Then go to test whether it can connect to the database, generally speaking, it will succeed
Insert picture description here

By the way, for sub-operations like the above, we need to reset the value of " serverTimezone " every time we create a new project . For convenience, we can go to IDEA and change the default value of " serverTimezone " to "UTC" "This will save a lot of trouble
Insert picture description here
Insert picture description here

This way we don't need to set the value of " serverTimezone " frequently in the future .

Guess you like

Origin blog.csdn.net/weixin_45309636/article/details/108024640