It is similar to a memo that the acquired double-byte characters are garbled and have been confirmed and resolved.
Data obtained by using Java's Http Client I'm trying to connect to MySQL using a JDBC driver and put it in the DB.
Did you cast the usual spell when you created the table? The usual spells are:
set character_set_client = utf8;
set character_set_connection = utf8;
CREATE TABLE `TABLE_NAME` (
(Abbreviation)
) DEFAULT CHARSET=utf8';
The point is to cast the spell before casting the SQL, If you're worried, cast the spell at the end of the CREATE TABLE statement.
Are you casting a spell when building a request with HttpClient?
HttpClient client = HttpClient.newBuilder().version(Version.HTTP_2).build();
Builder requestBuilder = HttpRequest.newBuilder().uri(uri).setHeader("Content-type","application/json; charset=UTF-8");
HttpRequest request = requestBuilder.build();
The charset = UTF-8
behind setHeader is the spell.
Are you casting spells in the JDBC driver settings?
dbconnection.properties
driver.class.name=com.mysql.jdbc.Driver
uri=jdbc:mysql://mysql.test.com/mydb?useUnicode=true&characterEncoding=utf8
The above mysql.test.com
is the connection destination and mydb
is the database name.
Notice the subsequent ? UseUnicode = true & characterEncoding = utf8
.
I'm casting a spell.
In my case, that solved. I've implemented something similar in exactly the same environment, but at that time the characters weren't garbled ...
Recommended Posts