中国人用中文一定要走弯路吗?-->MySQL5
环境:中文Windows2003 + JBuilderX + MySQL5 + Tomcat4 + mysql-connector-java-3.0.11-stable + Struts1.1(在struts_config.xml中用 odbc:mysql://localhost/ec?useUnicode=true&characterEncoding=gb2312 设定数据源)
问题:
在Servlet中
statement.execute ( "INSERT INTO my_table(FieldName) VALUES('中国人')" );
resultSet= statement.execute ( "SELECT * FROM my_table" ) ;
statement.getResultSet();
resultSet.last();
String result = resultSet.getString(1);
在JBuilderX中调度看到的restult永远是乱码。
已经尝试的解决方法:
MySQL中用:mysqld default-character-set=utf8
数据源中用:odbc:mysql://localhost/ec?useUnicode=true&characterEncoding=gb2312
要求:不用new String ( Src.getBytes(), "gb2312" );之类的间接方法
谢谢!