I use the below java code to insert data in mysql
private Long insertMFPatient() {
KeyHolder keyHolder = new GeneratedKeyHolder();
jdbcTemplate.update(new PreparedStatementCreator() {
public PreparedStatement createPreparedStatement(
Connection connection) throws SQLException {
PreparedStatement ps = connection.prepareStatement(
"insert into test(firstname, lastname) values(?,?)",
new String[] { "changeid" });
ps.setString(1, "mamá");
ps.setString(2, "test2");
return ps;
}
}, keyHolder);
return keyHolder.getKey().longValue();
}
On inserting text like mamá the data stored in mysql is mamá What should I do to correct this ? So far 1. I have updated the table encoding type to UTF-8 2. updated the connectionstring like jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8
Please help