Java PreparedStatement setString changes characters

前端 未结 3 1659
北海茫月
北海茫月 2021-01-20 05:00

As in title: to be sure, I was debugging my application, and so in line, where I put strings into PreparedStatement variable, special characters are changing to \"?\". I act

3条回答
  •  太阳男子
    2021-01-20 05:32

    this normally happens by using different charsets in different locations. sound like you're getting your input as UTF-8, converting it to another chatset (maybe your database is set to something else) which breaks the special character.

    to fix this: use the same charset everywhere*. (i would recommend using UTF-8)

    *take a look at this or my answer to another thread (that's about a problem in php, but in java it's almost the same)

提交回复
热议问题