Пример #1
0
 public void deleteUser(UserTo user) throws SQLException, ClassNotFoundException {
   String deleteSql = "delete from User where user_name = ?";
   con = JdbcUtil.getConnection();
   stmt = con.prepareStatement(deleteSql);
   stmt.setString(1, user.getUserName());
   stmt.executeUpdate();
   stmt.close();
   con.close();
 }
Пример #2
0
  public UserTo getUser(UserTo user) throws SQLException, ClassNotFoundException {
    String sqlQuery = "Select * from User where user_name = ?";
    con = JdbcUtil.getConnection();
    stmt = con.prepareStatement(sqlQuery);
    stmt.setString(1, user.getUserName());
    ResultSet rs = stmt.executeQuery();

    return getUserObjectFrom(rs);
  }
Пример #3
0
  public void insertUser(UserTo user) throws SQLException, ClassNotFoundException {
    String insertSql =
        "insert into User (first_name, last_name, user_name, user_password, activated, conf_key, created_date) values(?, ?, ?, ?, ?, ?, ?)";
    con = JdbcUtil.getConnection();
    stmt = con.prepareStatement(insertSql);
    stmt.setString(1, user.getFirstName());
    stmt.setString(2, user.getLastName());
    stmt.setString(3, user.getUserName());
    stmt.setString(4, user.getUserPassword());
    stmt.setString(5, user.getActivated());
    stmt.setString(6, user.getConfKey());
    stmt.setDate(7, DateUtil.convertJavaUtilDateToSqlDate(new Date()));

    stmt.executeUpdate();
    stmt.close();
    con.close();
  }