1、我在mysql数据库中建了一张中文字段的表
create table test(
姓名 varchar(20)
)
2、然后用jdbc中的PreparedStatement对象执行插入或修改操作报错,好像sql中的中文列名变成了乱码,不能成功执行。
部分sql语句如下:
[color=red] PreparedStatement pstmt = conn.prepareStatement("insert into test(姓名) values('00001')");[/color]
或者
[color=red] PreparedStatement pstmt = conn.prepareStatement("update test set 姓名
='1111'");[/color]
然后执行:
[color=red]pstmt.executeUpdate();[/color]
报如下错误:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '??) values('00001')' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
……………………
最近操作别人公司的mysql业务数据库,其中所有表的字段都是中文的,我有没办法改,所以必须使用中文的,没到万不得已,我一般打死都不在数据库中用中文(作为一个中国人的悲哀!!)。
请哪位帮忙解决下,急用!!!!!!!!
先感谢!!!!