日期:2014-05-17 浏览次数:20789 次
public int insert(User user){ int count = 0; Connection conn = null; PreparedStatement ps = null; //根据user对象的属性生成sql语句 String sql = "insert into user(tel,username,addr,mail,type,num,yf) values('"+user.getTel()+"','"+user.getUsername()+"','"+user.getAddr()+"','"+user.getMail()+"','"+user.getType()+"','"+user.getNum()+"','"+user.getYf()+"')"; try { conn = getConnection(); ps = conn.prepareStatement(sql); count = ps.executeUpdate(); } catch (SQLException e) { System.out.println("Sql异常2"); } finally{ if(ps!=null){ try { ps.close(); } catch (SQLException e) { System.out.println("关闭ps时异常"); } } if(conn!=null){ try { conn.close(); } catch (SQLException e) { System.out.println("关闭conn时异常"); } } } return count; }
恭喜,你已经成功订阅!<br> 您订阅的名字为: <% out.println(request.getParameter("username"));%><br> 您订阅的手机号码为:<%out.println(request.getParameter("tel")); %><br> 您订阅的地址为:<% out.println(request.getParameter("addr"));%><br> 您订阅的邮箱为:<% out.println(request.getParameter("mail"));%><br> 您订阅的种类为:<% out.println(request.getParameter("type"));%><br><br>