Java Preparedstatement UTF-8 character problem

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
分享
二维码
< <上一篇
下一篇>>