Reputation: 1918
If I have this query from java:
String query="insert into user (..., name, ...) values (..., 'à', ...)";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/Spinning?user=root");
PreparedStatement prest = con.prepareStatement(query);
prest.executeUpdate();
In the db I will have a strange character: a diamond with a question mark inside.
Is there any solution to this problem?
Upvotes: 3
Views: 2056
Reputation: 26858
Change your connection url to the following:
jdbc:mysql://localhost/Spinning?user=root&useUnicode=true&characterEncoding=utf8
Upvotes: 3
Reputation: 1504
SHOW CREATE TABLE xxxx
" to print the table DDL with charset being used.ConnectorJ,
you can set charset in the JDBC url.Upvotes: 1