Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Project/src/Controller/Connect.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package Controller;
import java.sql.*;

/**
* Created by dajun on 4/30/17.
*/
public class Connect {

private Connection connection;

//jdbc library loaded
public Connect() throws ClassNotFoundException, SQLException {

Class.forName("com.mysql.jdbc.Driver");
connection =DriverManager.getConnection("jdbc:mysql://localhost:3306/splendor","root","1234");

}

//disconnect from database
public void disconnect() throws SQLException {
connection.close();
}

//execute query to validate if the username matches with the password
public boolean verify(String usr, String pin) throws SQLException {

Statement stmt= connection.createStatement();
ResultSet rs=stmt.executeQuery("select password from users where username = '" + usr +"'");
if(rs.first()){
String password = rs.getString(1);
if(password.equals(pin)) {
return true;
}
}

return false;

}


}


Loading