0

Through our REST Webservices I want to insert double byte (utf-8) characters in MySql Database which is located on AWS cloud .

We have 2 db instances on cloud:

  1. local
  2. dev

We are using Tomcat server on our Windows machine and did all required changes for utf-8 support at db level and everything working perfectly fine and we are able to insert/update/fetch special characters through our code from local tomcat (whereas local DB is located on cloud only).

But when we are trying to insert the special characters by hitting the same services deployed on AWS EC2 UniBox DEV environment which is pointing to DB of DEV instance which is also located on cloud same as local db instance, we are getting below mentioned error :

{
  "errorCode": 500,
  "message": "Database Connection/SQL Error.",
  "error": "CallableStatementCallback; uncategorized SQLException for SQL [{call sp_sign_up_insert(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)}]; SQL state [HY000]; error code [1366]; Incorrect string value: '\\xAC\\xED\\x00\\x05t\\x00...' for column 'host_first_name' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\\xAC\\xED\\x00\\x05t\\x00...' for column 'host_first_name' at row 1"
}

We have configured our Database's connection details from Tomcat's server.xml and the same entries are present on dev environment's server.xml as well.

I tried many things by tweaking entries of server.xml located on DEV environment with reference to blogs and many more but nothing has worked......

It would be of great help if anyone can suggest that what might be the reason due to which we are facing issues performing same thing on DEV env when it is working perfectly fine from local.

Thanks in Advance !!! In real need of your inputs :)

Community
  • 1
  • 1
shuchi
  • 81
  • 1
  • 1
  • 3
  • ACED00 is strange, where did it come from? What "double byte" characters are you using -- Greek, Cyrillic, Arabic, BIG5, ...? – Rick James Dec 18 '16 at 03:59
  • you might want to check your server settings, client settings, and schemas in both places. Default charsets can throw things off, and it's not at all uncommon for various testing databases to have something like this wrong – erik258 Dec 19 '16 at 04:33
  • Thanks @RickJames & DanFarrell for your reply... – shuchi Dec 19 '16 at 12:23
  • @RickJames: We are using Chinese & Japanese characters, now our things are working on DEV and TEST env as well after changing the data type from VARCHAR to TEXT. But still we are surprised that how it is working on Local env with VARCHAR data type only. – shuchi Dec 19 '16 at 12:30
  • Japanese needs 3 bytes per character when using utf8; Chinese needs 3 or 4. With BIG5, Chinese needs only 2 bytes per 'character'. Please clarify the title as to which encoding you are using in the client. – Rick James Dec 19 '16 at 16:22

1 Answers1

1

MySQL/MariaDB errors that look like Incorrect string value: '\\xAC\\xED\\x00\\x05t\\x00...' for column or Invalid utf8 character string: 'ACED00' mean you probably have a bug in your code.

AC ED 00 .. are first bytes of a Java serialized object, meaning you are trying to bind a Java object of an unsupported type to a SQL query (also remember that raw arrays are unsuitable for binding to SQL).

Only certain Java types can be bound to SQL, as described in Mapping SQL and Java Types.

rustyx
  • 80,671
  • 25
  • 200
  • 267