I\'m trying to connect to a database I created with MySQL in my Java program, but it always fails.
For the sake of example, here is my code:
import j
It might be because you're using an older version of the MySQL driver. You should try using the newest version.
To get the newest version, you can check https://mvnrepository.com/artifact/mysql/mysql-connector-java
As of right now, the newest version is 8.0.11. You can download it here or add this to your pom.xml
:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
</dependency>
Upon further investigation, it seems that it's because of a change that was introduced in MySQL 8.0.1
:
The issue you reported is related to the changes introduced in MySQL 8.0.1 wrt the character sets and collations support, with the addition of now being 'utf8mb4' the default char set. Such changes broke the way Connector/J initializes connections.
As you know this was fixed in Connector/J 5.1.41 and I'm sure you already updated your library.
reference
Like mentionned above, an alternative fix to your problem would have been to use the 5.1.41
instead of 5.1.40
.
If you call the IP address 127.0.0.1/localhost then you are communicating with the localhost – in principle, with your own computer.This issue also appears when you don't have localhost configured
For Linux systems
For Windows system
For more details on localhost
Sounds like a potential version mismatch or outdated client. When you run it outside the IDE you may be pulling in the wrong version. I'd make sure the client is on the latest version or similar to the version used by the server.