5
 java.sql.SQLException: Incorrect string value: '\xAC\xED\x00\x05sr...' for column 'xxxx'

The column is a longtext in MYSQL with utf8 charset and utf8_general_ci collation.

What is wrong?

2
  • I'm reading the bytes from a server using utf-8(or ISO8859-1, or whatever), then create a StringBuffer, then pass it to hibernate, it then save it Commented Apr 21, 2010 at 23:44
  • Can you add some debug to show the contents of the StringBuffer before you send it to the database, and then post that here? Commented Apr 22, 2010 at 17:13

5 Answers 5

8

It's a bit late, but you might want to know that \xAC\xED\x00\x05sr... is a magic number for Java serialization. Apparently your parameter is being serialized instead of being pasted as a string.

Sign up to request clarification or add additional context in comments.

1 Comment

Yep, that was my problem. I was trying to insert an ArrayList as-is into a MySQL VARCHAR.
2

Assuming that those are hexadecimal escape codes, the text \xAC\xED\x00\x05sr... is not a valid UTF-8 string.

Comments

1

Is this while using PreparedStatements in Groovy? If so, you're using GStrings instead of plain Java Strings. Check your object yo make sure your parameters are what you expect.

Comments

0

change your table to latin1 encoding or utf8mb4

Comments

0
ALTER TABLE your_table CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;

You can try this.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.