Java PreparedStatement UTF-8 character problem

前端 未结 4 1701
长情又很酷
长情又很酷 2020-12-06 02:15

I have a prepared statement:

PreparedStatement st;

and at my code i try to use st.setString method.

st.setString(1, userNa         


        
4条回答
  •  不知归路
    2020-12-06 03:04

    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

    You should also check that the table / column character set is UTF-8.

提交回复
热议问题