Java PreparedStatement UTF-8字符问题 [英] Java PreparedStatement UTF-8 character problem

查看:449
本文介绍了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.

这篇关于Java PreparedStatement UTF-8字符问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆