写表的时候要进行对中文的转化
<%!
public String getStr(String str)
{
        try
        {
                String temp_p=str;
                byte[] temp_t=temp_p.getBytes("iso-8859-1");
                String temp=new String(temp_t);
                return temp;
        }        catch(Exception e)
        {
        }
        return "null";
}
%>
String xx=...;
xx=getStr(xx);

解决方案 »

  1.   

    String sql_new = new String(sql_old.getBytes("8859_1"),"gb2312");
      

  2.   

    1.控制面板-区域设置-英文(或直接安装英文版OS) 
    2.JSP页面中加入一条语句: 
    <%@ page contentType="text/html;charset=gb2312" %> 
    3.编译servlet使用: 
    javac -encoding iso8859-1 myservlet.java 
    在jsp的zone配置文件中,修改编译参数为: 
    compiler = builtin-javac -encoding ISO8859-1 
    4.CLASSPATH中加入i18n.jar的路径 
    5.源程序中加入代码变换函数: 
    <%! 
    public String getStr(String str){ 
    try{ 
    String temp_p = str; 
    byte[] temp_t = temp_p.getBytes("ISO8859-1"); 
    String temp = new String(temp_t); 
    return temp; 

    catch(Exception e){} 
    return "null"; 

    %> 
    6.如果是直接赋值的中文字串,用<%@ page contentType="text/html;charset=gb2312" %> 
    就足够了。 
    7.如果使用request传过来的中文字串,用getStr(String)方法转换后使用。