While establishing the connection to a MySQL database, I\'m getting the following error
java.sql.SQLException: Unknown initial character set index \'255\' receiv
Use Version 5.1.44 of mysql-connector-java.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.44</version>
</dependency>
it is because of mysql-connector version , i,e. My-sql install version and dependency version did not match.
use same version for myS
Using MySQLWorkbench interface:
First click in your connection ->
After click in Options File
And change character-set-server and collation-server values to the values below:
Make sure to restart mysql server by opening services and restarting mysql server.
The way I fixed it : Add characterEncoding=utf8 to the end of jdbc connection string
E.g. connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/photo_app?" + "user=root&password=root&characterEncoding=utf8");
You can add ?characterEncoding=latin1"
after your url String like this
for e.g.:
"jdbc:mysql://localhost/yourDB?characterEncoding=latin1";
It might work.
Compatible version of mysql-connector-java should be required as per installed MySQL Server ---> For my installed MySQL Server 8.0 I download mysql-connector-java-8.0.20 in SoapUi/bin/ext folder or build path of project in eclipse. it works for me!!