首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

jsp向sql2000平添数据为null

2013-04-20 
jsp向sql2000添加数据为nullform methodpost namef1 actionCustomerAddServletlabel姓名:/l

jsp向sql2000添加数据为null
<form method="post" name="f1" action="CustomerAddServlet">
      <label>姓名:</label><input type="text" name="CustomerName">
       <label>电话:</label><input type="text" name="Phone">
      <label>手机:</label><input type="text" name="CellPhone">
      <label>地址:</label><input type="text" name="Address">
      <input type="submit" value="添加"> 
    </form>

String sql="insert into Sales_Customer(CustomerName,Phone,CellPhone,Address,ModifiedDate) values(?,?,?,?,?)";
    String customerName=request.getParameter("CustomerName");
    String phone=request.getParameter("Phone");
    String cellPhone=request.getParameter("CellPhone");
    String address=request.getParameter("Address");
    Dao dao = new Dao();
    Connection conn=dao.getConnection();
    PreparedStatement ps=conn.prepareStatement(sql);
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
    Date now = new Date();//获取当前时间
    String ModifiedDate=df.format(now);
    ps.setString(1,customerName);
    ps.setString(2,phone);
    ps.setString(3,cellPhone);
    ps.setString(4,address);
    ps.setString(5,ModifiedDate);
    int row=ps.executeUpdate();
    if(row>0){
    System.out.println("成功添加");
    }
    ps.close();
    conn.close();
除了表里主键CustomerID自增长和ModifiedDate有值,其他都是null·为什么啊?

jsp向sql2000平添数据为null
jsp向sql2000平添数据为null SQL JSP
[解决办法]
调试看下 获取的值 是否为空
[解决办法]

conn.commit
需要提交

热点排行