質問

I'm running java over jetty, on an EC2 linux instance, using MySQL DB. The column is a VARCHAR, set to accept utf8mb4 encoding.

After playing around with stuff, I've found out that it works when I run this code through gradle jettyRunWar, or even when running the same code on a tomcat server.

It doesn't work when I place the exact same war that was working before in $JETTY_HOME/webapps/root.war, then run jetty with sudo service jetty start.

The error shown is -

java.sql.BatchUpdateException: Incorrect string value: '\xF0\x9F\x99\x89' for column 'name' at row 1

Current column definition -

`name` varchar(50) CHARACTER SET utf8mb4 DEFAULT NULL

Value is set in SQL through preparedStatement.setString(...) and I made sure that mysql connector JAR is the same.

Any ideas?

役に立ちましたか?

解決

Problem resolved once I've set all character_set_... MySQL DB variables to utf8mb4.

That probably means that newer version of jetty (8+) treat JDBC connection different than Tomcat or than older version, because the exact connection string, beans definition & DB was used at all cases.

Until now, character_set_... params were set to utf8 with specific columns defined as utf8mb4, that used to be enough.

Hopes that saves anyone else the day I was stuck on it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top