Java PreparedStatement UTF-8字符问题
我有一份准备的声明:
PreparedStatement st;
在我的代码我尝试使用st.setString方法。
and at my code i try to use st.setString method.
st.setString(1, userName);
userName的值为şakça。 setString方法将şakça更改为?akça。它不识别UTF-8字符。我如何解决这个问题?
Value of userName is şakça. setString methods changes 'şakça' to '?akça'. It doesnt recognize UTF-8 characters. How can i solve this problem?
谢谢。
数量的方式,这可以被拧紧实际上是令人印象深刻。如果您使用MySQL,请尝试在JDBC连接网址的末尾添加 characterEncoding = UTF-8
参数:
The number of ways this can get screwed up is actually quite impressive. If you're using MySQL, try adding a characterEncoding=UTF-8
parameter to the end of your JDBC connection URL:
jdbc:mysql:// server / database?characterEncoding = UTF-8
表/列字符集是UTF-8。
You should also check that the table / column character set is UTF-8.