Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class LoginDAO {
- private Connection connection;
- public LoginDAO() throws SQLException{
- String jdbs = "jdbc:postgresql://localhost:5432/postgres?currentSchema=chatroom";
- String user = "postgres";
- String password = "171025";
- connection = DriverManager.getConnection(jdbs, user, password);
- System.out.println("DB connetion successful to " + jdbs);
- }
- public void register(String username, String password) throws SQLException{
- }
- public boolean login(String username, String password) throws SQLException{
- PreparedStatement myStmt = connection.prepareStatement(
- "SELECT password FROM login WHERE username=?"
- );
- myStmt.setString(1, username);
- ResultSet rs = myStmt.executeQuery();
- while(rs.next()){
- String passwordCheck = rs.getString("password");
- if(passwordCheck.equals(password)){
- return true;
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement