Okay ill try to keep this short. I have Java web site and MySQL Database. Everything uses UTF-8 charset. Problem is that if i try to insert Lithuanian letters into database all letters like "ą č ę ė į ų ū" are converted into question marks.
Insert code:
public static boolean addUser(UserEntity userEntity) {
Connection con = getDataBaseConnection();
PreparedStatement statement = null;
try {
if (userEntity.isIsActive()) {
booleanInt = 1;
} else {
booleanInt = 0;
}
if (con != null && !con.isClosed()) {
statement = con.prepareStatement("INSERT INTO users (login,"
+ " firstName,"
+ " lastName,"
+ " personalId,"
+ " isActive,"
+ " password)"
+ "VALUES(?,?,?,?,?,?)");
statement.setString(1, userEntity.getLogin());
statement.setString(2, userEntity.getFirstName());
statement.setString(3, userEntity.getLastName());
statement.setString(4, userEntity.getPersonalId());
statement.setInt(5, booleanInt);
statement.setString(6, userEntity.getPassword());
System.out.println(statement.toString());
//statement.executeUpdate();
return statement.execute();
}
} catch (Exception ex) {
System.out.println(ex);
} finally {
closeConnection(con);
return false;
}
If we print out for userEntity.getLogin it prints out everything with letters as it should be. Lets say its Mažeikiai. If we print out prepared SQL statement it will be replaced. Java is set to work with UTF-8, GlassFish, database also.