Java Preparedstatement UTF-8 character problem
•
Java
I have a prepared statement:
PreparedStatement st;
In my code, I try to use the st.setstring method
st.setString(1,userName);
The value of username is ş AK ç a. setstring method ş AK ç a 'changed to'? akça’. It does not recognize UTF - 8 characters How can I solve this problem?
thank you.
Solution
The way this can be screwed up is actually impressive If you use mysql, try adding a characterencoding = UTF-8 parameter at the end of the JDBC connection URL:
JDBC: MySQL: / / server / database characterencoding = UTF-8
You should also check that the table / column character set is UTF-8
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码