Reputation: 11484
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();
Upvotes: 0
Views: 2038
Reputation: 11484
I figured it out. I needed to put characterEncoding=UTF-8
into the JDBC connection URL.
Read more here: https://dev.mysql.com/doc/connector-j/5.1/en/connector-j-reference-charsets.html
Upvotes: 1