public void addUser(User user) throws SQLException {
    Connection conn = getConnection();

    PreparedStatement ps =
        conn.prepareStatement("insert into users(id, name, password) values (?, ?, ?)");
    ps.setString(1, user.getId());
    ps.setString(2, user.getName());
    ps.setString(3, user.getPassword());

    ps.executeUpdate();

    ps.close();
    conn.close();
  }
  public User getUser(String id) throws SQLException {
    Connection conn = getConnection();

    PreparedStatement ps = conn.prepareStatement("select * from users where id = ?");
    ps.setString(1, id);

    User user = new User();
    ResultSet rs = ps.executeQuery();
    if (rs.next()) {
      user.setId(rs.getString("id"));
      user.setName(rs.getString("name"));
      user.setPassword(rs.getString("password"));
    }

    rs.close();
    ps.close();
    conn.close();

    return user;
  }