我把“stmt.execute(sql)”换成了“stmt.executeQuery(sql)”还是不行啊,执行后提示“exec 'INSERT INTO FS_REPORT_SALE_CUSTOMER_DAY_FQ' err!"”,大哥,请再指教!

解决方案 »

  1.   

    你把SQL语句打印出来,然后放在数据库下RUN一下,有可能是你字符串错了。
      

  2.   

    谢谢!我用“stmt.executeUpdate(sql);”方法成功了,可就是我插入的“et”字段的“北京市场”在数据库里查出来竟变成了“????”即四个问号,我现在用的是JCreator2.5,我该怎么弄?
      

  3.   

    我把它改成了
    String sql = "INSERT INTO fs_report_sale_customer_day_fq "+
            "(report_date,reason_no,et,district_no,customer_no) "+
            "VALUES "+ 
            "('2002-10-18','*',N'北京市场','1001','12345678')";在数据库中查询,“北京市场”还是“????”,请继续指教……
      

  4.   

    给你一个简单的方法:
    public String getChinese(String str)
      {
        String strCN = null;
        try{
          if(str==null||str.equals("")){str = "";}
          byte[] temp = str.getBytes("iso-8859-1");
          strCN = new String(temp);
        }catch(Exception e)
        {
          e.printStackTrace();
        }
        return strCN;
      }
    //
    String sql = "INSERT INTO fs_report_sale_customer_day_fq "+
        "(report_date,reason_no,et,district_no,customer_no) "+
                    "VALUES "+ 
         "('2002-10-18','*',‘“+this.getChinese("北京市场")+”’,'1001','12345678');";
    这样调用转码方法吧
      

  5.   

    <%@ page contentType="text/html;charset=gb2312""%>
    String str=rs.getString("北京市场");
    result=new String(str.getBytes("ISO8859_1"),"gb2312");
    String sql = "INSERT INTO fs_report_sale_customer_day_fq "+
            "(report_date,reason_no,et,district_no,customer_no) "+
            "VALUES "+ 
            "('2002-10-18','*',"+result+",'1001','12345678')";
      

  6.   

    String str = new String("北京市场");
         String strCN = null;  
         try{
          byte[] temp = str.getBytes("iso-8859-1");
          strCN = new String(temp);
         }catch(Exception e)
         {e.printStackTrace();}     String sql = "INSERT INTO fs_report_sale_customer_day_fq "+
                 "(report_date,reason_no,et,district_no,customer_no) "+
                 "VALUES "+ 
                 "('2009-11-12','*','"+strCN+"','1001','12345678')";     
         stmt.executeUpdate(sql);执行如上代码,数据库里新插入记录“et”字段的值还是“????”,郁闷大半天了!
    我试着用楼上兄才mtou()的方法,
    “<%@ page contentType="text/html;charset=gb2312""%>”编译通不过,提示说是“不合法的表达式”。
      

  7.   

    <%@ page contentType="text/html;charset=gb2312""%>,这句话最后一个引号是多余的