-1

I've set the column type to utf8mb4 and the collation to utf8mb4_bin. The table defaults are also utf8mb4 and utf8mb4_bin.

When I use SequelPro to add the emoji "🤖" to the database manually, it works just fine.

However, when I do an INSERT using JDBC, it gives me the Incorrect String Value error.

Here is my connection string: jdbc:mysql://localhost:3306/myschema
I'm using mysql-connector-java-5.1.32-bin.jar

What am I doing wrong?

Here is some of the code I'm using:

String sql = "INSERT INTO table VALUES (?)"
String body = ...;
statement = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
statement.setString(1, body)
statement.execute();

closed as off-topic by a_horse_with_no_name, mustaccio, LowlyDBA, Gaius, Marco Mar 12 at 12:05

If this question can be reworded to fit the rules in the help center, please edit the question.

  • One thing you're doing wrong is not posting your code. Another one is you post your question on the wrong site. – mustaccio Mar 5 at 15:51
  • added some code. – satnam Mar 5 at 17:19
  • You also need to connect with utf8mb4: ?useUnicode=yes&characterEncoding=UTF-8 – Rick James Mar 11 at 22:36
1

You probably should upgrade your MySQL Java connector to a later version, best to the one matching your MySQL server. utf8mb4 support was added in version 5.5.3.

Not the answer you're looking for? Browse other questions tagged or ask your own question.