0

电话号码字段出现错误...虽然我给出了 long 或 int 它给出了相同的错误...请帮助我从表单中获取所有参数但不幸的是这个电话号码没有得到更新..它超出了范围int,所以我尝试了很长时间,但没有用...

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String update = " UPDATE cust_info_table SET cust_fname=?,cust_lname=?, phone_num=?, email_id=?, address=? WHERE cust_id=? ";
    try{

        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mutualfund", "root", "");

        PreparedStatement ps = con.prepareStatement(update);
        String fname = request.getParameter("fname");
          String lname = request.getParameter("lname");

          long phn = Integer.parseInt(request.getParameter("phn"));

          String mail = request.getParameter("mail");
          String addr = request.getParameter("addr");
          String uid = request.getParameter("uid");
        ps.setString(1,fname);
        ps.setString(2, lname);
        ps.setLong(3, phn);

        ps.setString(4, mail);
        ps.setString(5, addr);
        ps.setString(7,uid);
        ps.executeUpdate();
        con.close();
        response.sendRedirect("welcome.jsp?name="+uid);
    } 
    catch (Exception ex)
    {
        Logger.getLogger(Admin.class.getName()).log(Level.SEVERE, null, ex);
    }

}
4

1 回答 1

0

首先尝试以下方式.. long phn = Integer.parseInt("12312312"); 并注意这一点....

    ps.setString(4, mail);
    ps.setString(5, addr);
    ps.setString(7,uid);

它应该是“ ps.setString(6,uid);”。

于 2013-06-14T13:32:01.633 回答