String getname    = request.getParameter("name");
String getaddress = request.getParameter("address");
String cusidd = request.getParameter("id");         --这个id是int型,怎么接受呢,这样能成功,可是变成String了阿!!!
(所以要转换一下)
int cusidd1=Integer.parseInt(cusidd);
String Sqll = " update demo.customer set address='"+getaddress+"' , name = '"+getname+"' where customer_id='"+cusidd1+"' ";

解决方案 »

  1.   

    我也是新手。
    先测试一下,是否正确联系了数据库。
    简单的输出一条数据。
    如可以,测试插入一条数据,或者删除一条数据。
    如可以 再尝试转换cusidd为Int类型,"+Integer.parseInt(cusidd)+"'";
    另外你这个东西是在什么中写的?JFrame? jsp?
     如果是在JApplet或者Applet中的。是不可以的。你没有修改本地文件(数据库)的权限。
      

  2.   

    如果你怀疑sql有错,就System.out.println(Sqll);放到数据库里运行一下啊.
    问一句你用的是什么数据库,怎么表名里有"."?
    还有你既然捕捉了异常,为何什么都不做,最起码也要把数据库连接关掉啊.
      

  3.   

    int cusidd = Integer.parseInt(request.getParameter("id"));
      

  4.   

    1.可能你的customer_id字段是int型,所以要先转换一下cusidd的数据类型,才能正常的更新,
    2.关于如何判断SQL的对错,你可以写出来到SQL查询一下看看结果
    祝你好运
      

  5.   

    你得看看你的数据库中customer_id是什么类型,如果是整形 用where customer_id='"+cusidd1+"' 是不对的,应该把单引号去掉,如果你是在数据库中直接插入,那么数据库应该有错误提示阿。
      

  6.   


    对了,随便问一下你是什么数据库
    int cusidd1=Integer.parseInt(cusidd);
    如果是acess的话
    String Sqll = " update customer set address='"+getaddress+"' , name = '"+getname+"' where customer_id="+cusidd1
    如果是sql的话
    String Sqll = " update customer set address='"+getaddress+"' , name = '"+getname+"' where customer_id='"+cusidd1+"' ";
    用上面的试试看
      

  7.   

    customer_id='"+cusidd1+"' 是不对的,应该把单引号去掉
    或者把数据库中customer_id改为varchar
      

  8.   

    你应该从其他方面检查才是,转不转int类型没必要,where customer_id='"+cusidd+"' 和
    where customer_id="+cusidd+" 的区别在于前面的写法执行速度会比后面写法慢。
      

  9.   

    呵呵,应该不是数据类型的问题
    try{
         conn =ds.getConnection();
     pst = conn.createStatement();
     pst.executeQuery(Sqll);///这句是执行查询,返回resultSet,所以不对
              pst.close();
    }
    应该是int i=pst.executeUpdate(Sqll);////这样更新数据