日期:2014-05-18 浏览次数:20839 次
Connection conn = new Database().getConn(); String sqlStr = "insert into user (name,password,email,sex,tel) values (?,?,?,?,?)"; try { PreparedStatement ps = conn.prepareStatement(sqlStr); int i=1; ps.setString(i++, user.getName()); ps.setString(i++, user.getPassword()); ps.setString(i++, user.getEmail()); ps.setInt(i++, user.getSex().intValue()); ps.setString(i++, user.getTel()); ps.executeQuery(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }
Connection conn = new Database().getConn(); String sqlStr = "insert into user (name,password,email,sex,tel) values (?,?,?,?,?)"; try { PreparedStatement ps = conn.prepareStatement(sqlStr); int i=1; ps.setString(i++, user.getName()); ps.setString(i++, user.getPassword()); ps.setString(i++, user.getEmail()); [color=#FF0000]ps.setInt(i++, user.getSex().intValue());[/color] ps.setString(i++, user.getTel()); [color=#FF0000]ps.executeQuery();[/color] } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }