你可以看看我这个得分的例子
http://expert.csdn.net/Expert/topic/1529/1529097.xml?temp=.9971582我简单总结一下:
数据库存储最好用8859_1的格式,
所以存入数据库的时候进行一下编码转换,但我们通常的显示格式为GB2312或GBK,所以取出来的时候再转一次例如:存入数据库时用:
把数据转成8859_1的格式
name=new String(name.getBytes("gb2312"),"8859_1");
content=new String(content.getBytes("gb2312"),"8859_1");insert into (name,content)values(?,?).......从数据库取的时候用:
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/gfqqqqpe?user=gfqqqqpe_f&password=aaaaa&useUnicode=true;characterEncoding=8859_1");
从数据库取的时候指定编码方式为“8859_1”,
然后显示的时候进行转换:
name=new String(name.getBytes("8859_1"),"gb2312");
这种方法在MYSQL上通用你要查询的话,就应该把编码转换成8859_1来进行查询,see?