[Solved] com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException exception solution

The reason is that I imported the webapps project “woniusales.war” in tomcat, started tomcat by double-clicking startup.bat, and reported an error in the black box. Open localhost:8080/woniusales and find that the project was not successfully configured.

[Severe] com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException

The reason for the error is: the mysql version on the computer is high, and the mysql-java driver version in the project is too low, and the two do not match.

Solution steps:

1. mysql>select version(); Check the mqsql version, my version is 8.0.19.

2. Go to the official website to download the corresponding version of the mysql-java driver, MySQL :: Download MySQL Connector/J (Archived Versions)

Then unzip the file, in the webappswoniusalesWEB-INFlib folder, use mysql-connector-java-8.0.19.jar Replace the original mysql-connector-java-5.xxx.jar

3. Find the db.properties file in your project in the webapps directory and open it with Notepad.

db_url=jdbc:mysql://localhost:3306/xxxxxx add ** & amp;serverTimezone=UTC** at the end

db_username and db_password are the same as your local database username/password

Change db_driver to com.mysql.cj.jdbc.Driver (mysql 5.xxx driver class here is com.mysql.jdbc.Driver)

4. Double-click startup.bat again, there is no error, open localhost:8080/woniusales, the project runs successfully!

Last

I know that most junior and intermediate Java engineers want to improve their skills by exploring their own growth or signing up for classes, but for training institutions, the tuition fee is nearly 10,000, which is really stressful. The self-learning effect of unsystematic self-learning is inefficient and long, and it is very easy to hit the ceiling and the technology stagnates!

Therefore, we have collected and organized a set of “Java Development Complete Learning Materials” for you. The original intention is very simple. I hope to help friends who want to learn by themselves but don’t know where to start, and at the same time reduce everyone’s burden. burden.

The editor has encrypted: aHR0cHM6Ly9kb2NzLnFxLmNvbS9kb2MvRFVrVm9aSGxQZUVsTlkwUnc==For security reasons, we have encoded the website through base64, and you can get the website through base64 decoding.