大哥请帮忙!对数据库的插入操作 我把“stmt.execute(sql)”换成了“stmt.executeQuery(sql)”还是不行啊,执行后提示“exec 'INSERT INTO FS_REPORT_SALE_CUSTOMER_DAY_FQ' err!"”,大哥,请再指教! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你把SQL语句打印出来,然后放在数据库下RUN一下,有可能是你字符串错了。 谢谢!我用“stmt.executeUpdate(sql);”方法成功了,可就是我插入的“et”字段的“北京市场”在数据库里查出来竟变成了“????”即四个问号,我现在用的是JCreator2.5,我该怎么弄? 我把它改成了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')";在数据库中查询,“北京市场”还是“????”,请继续指教…… 给你一个简单的方法: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');";这样调用转码方法吧 <%@ 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')"; 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""%>”编译通不过,提示说是“不合法的表达式”。 <%@ page contentType="text/html;charset=gb2312""%>,这句话最后一个引号是多余的 求教!用Castor生成XML的问题 取属性的类型的问题 有对activemq研究的吗? 关于求职公司的问题 如何用servlet实现服务器推送! 高分相送:weblogic经常异常导致网页打不开 jacob word 转换成 xml 的问题? 用wsad开发一个管理系统,应该如何进行布局和架构设计? 有关struts的问题,返回页面结果不对!在线等待,以解决就结帖 springmvc 使用request向jsp传值,EL获取不到值 到那里可以找到包含javax.ejb.*的包? 移植到WebSphere的问题(急)?
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')";在数据库中查询,“北京市场”还是“????”,请继续指教……
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');";
这样调用转码方法吧
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')";
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""%>”编译通不过,提示说是“不合法的表达式”。