日期:2014-05-17 浏览次数:20940 次
public void add(UserModel um){ Connection conn = ConnectionDB.getConn(); String sql = "insert into users values(?,?,null,?,?,?)"; PreparedStatement ps = ConnectionDB.prepare(conn, sql); //UserModel um1 = new UserModel(); //String busID = new String(request.getParameter("busID").getBytes("ISO8859_1"),"utf-8"); //String ownTO = new String(request.getParameter("ownTO").getBytes("ISO8859_1"),"utf-8"); //System.out.println(um1.getUsername()+um1.getPassword() // +"/n"+um1.getSex()+"/n"+um1.getTelephone()+"/n"+um1.getEmail()); try { [color=#FF0000]ps.setString(1, um.getUsername());[/color] ps.setString(2, um.getPassword()); ps.setString(4, um.getSex()); ps.setString(5, um.getTelephone()); ps.setString(6, um.getEmail()); ps.executeUpdate(); System.out.println("register success....."); } catch (SQLException e) { e.printStackTrace(); } ConnectionDB.close(ps); ConnectionDB.close(conn); } }
public String add(){ //um = new UserModel(); [color=#FF0000]uls.add(um);[/color] System.out.println(um.getUsername()); return SUCCESS; }