Unable to connect MySQL server at localhost 3306 using netbeans 11.3

5.8k Views Asked by At

In the Maven project. When I first set up XAMPP and MySQL work very well. But inside NetBeans I can't connect to the MySQL and can't create a connect to the mysql-connector-java-8.0.20.zip or mysql-connector-java-8.0.20.jar. driver="com.mysql.cj.jdbc.Driver" and url="jdbc:mysql://localhost:3306/mysql" enter image description here enter image description here

When I going to add new connection to MySQL it display error message,

Cannot establish a connection to jdbc:mysql://localhost:3306/mysql using com.mysql.cj.jdbc.Driver (The server time zone value 'unknown' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver

enter image description here 

2

There are 2 best solutions below

0
On

"The server time zone value 'unknown' is unrecognized or represents more than one-time zone" This is a common error in MySQL to fix this error.
1)Create a new connection to MySQL
2)Connect JDBC driver to using mysql-connector-java-8.0.20.jar
3)In JDBC URL add server time zone as follows make sure your database name is mysql otherwise change the database name to your database name.
jdbc:mysql://localhost:3306/mysql?serverTimezone=UTC
NB:-If you want you can add server time zone as a connection property set property as serverTimezone and value as UTC.

If this didn't work use MariaDb driver to connect MySQL
1)Create a new connection
2)Add mariadb-java-client-2.6.0 to the connection
3)In JDBC URL add as follows and you don't want to worry about server time zone when you use MariaDB
jdbc:mariadb://localhost:3306/mysql

0
On

It looks like you're running on windows but the solution for me involved customizing the mysql driver. On the netbeans services tab open the drivers folder right-click the mysql connector/driver and then cutomize. Locate your driver on your system and add it to the class then click ok. Worked for me on ubuntu