While establishing the connection to a MySQL database, I\'m getting the following error
java.sql.SQLException: Unknown initial character set index \'255\' receiv
Sounds like you need to download the latest connector j jar:
http://chillyfacts.com/java-sql-sqlexception-unknown-initial-character-set-index-224-received-server/
I am using springboot
,liquibase
, mysql
I got solution:
This error occur just because of mysql connector in dependency and mysql server you install not match(in my case i am using lower version mysql connector and latest mysql server). So just change scope of mysql connector to runtime
:
maven
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
gradle
dependencies {
//... other dependencies
runtimeOnly group:'mysql', name:'mysql-connector-java'
}
Or if problem yet not solve then use same version or nearby version for both mysql server and mysql connector.
Adding the following to your connection string should work:
jdbc:mysql://localhost/yourDB?characterEncoding=latin1;
Use the same version of MySQL as well as mysql-connector. If you are using tomcat then keep the connector in the lib folder of tomcat.
Setting the CharacterEnconding, useUnicode options will work
jdbc:mysql://localhost:3306/dbname?characterEncoding=utf8&useSSL=false&useUnicode=true"
Add connector dependency jar file in the POM file after a cross-check with your MySql server version 8.0.x add this dependency it was working for me mysqlmysql-connector-java 8.0.11