Example #1
0
 public int create(User user) {
   try {
     Statement stat = conn.createStatement();
     ResultSet rs = stat.executeQuery("Select ID FROM USERS ");
     int i = user.getId();
     String n = user.getName();
     String pass = user.getPassword();
     Date d = user.getDate();
     System.out.println("i= " + i);
     stat.execute(
         "INSERT INTO USERS VALUES("
             + i
             + ",'"
             + n
             + "', '"
             + pass
             + "', TO_DATE('"
             + d
             + "','YYYY-MM-DD'))");
   } catch (SQLException e) {
     e.printStackTrace();
     System.out.println("Alarm in addUser");
   }
   return 1;
 }
Example #2
0
  public void add(final User user) throws ClassNotFoundException, SQLException {

    final String query = "insert into userinfo (id, name, password) values (?,?,?)";
    final String[] params = new String[] {user.getId(), user.getName(), user.getPassword()};

    getJdbcTemplate().update(query, params);
  }
Example #3
0
  public User readByNamePass(String login, String pass) {
    List<User> list = findAll();

    for (User u : list) {
      if (u.getName().equals(login) && u.getPassword().equals(pass)) ;
      return u;
    }
    System.out.println("Неправильный логин или пароль");
    return null;
  }