Arabic characters issues with MySQL database using Java

  • 0
  • Pump00:00

I am having a bit of trouble collating Arabic characters into MySQL database using Java.

I am using utf8 for all my tables and my database. Here are some screenshots from Mysql Workbench:


The String that I tried to collate is: عماد

It’s worth mentioning that Arabic is coded over 2 bytes, so this is clearly not an issue of regular utf8 not being able to handle Arabic.

Code for connecting to the database:

String url = "jdbc:mysql://";
String user = "root";
String passwd = ".........";
String unicode= "?useUnicode=yes&characterEncoding=UTF-8";

setConnection((Connection) DriverManager.getConnection(url+unicode, user, passwd));

Code for inserting the value:

query3 = "INSERT INTO keyword (idkeyword, keyword) VALUES ("+keyWord.getId()+",'عماد')";
Statement state7 = (Statement) connection.createStatement();

The exception that I’m receiving:

java.sql.SQLException: Incorrect string value: 'xD8xB9xD9x85xD8xA7...' for column 'keyword' at row 1
at com.mysql.jdbc.SQLError.createSQLException(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.checkErrorPacket(
at com.mysql.jdbc.MysqlIO.sendCommand(
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(
at com.mysql.jdbc.ConnectionImpl.execSQL(
at com.mysql.jdbc.StatementImpl.executeUpdateInternal(
at com.mysql.jdbc.StatementImpl.executeLargeUpdate(
at com.mysql.jdbc.StatementImpl.executeUpdate(
at controller.DataBaseAccess.saveProject(

All help is greatly appreciated!

Default Asked on December 28, 2019 in Programming.
Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.