Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package database;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.util.ArrayList;
- import database.mainConnection;
- public class userUtils extends mainConnection {
- public static void main(String[] args ) throws Exception {
- userLogin("mattia",hash("password");
- }
- /*public static Boolean registerUser(String name, String surname, String username, String email, String password, String Affiliation, String dateOfBirth) throws Exception {
- Connection con = getConnection();
- // 0000-00-00 format date
- PreparedStatement query = con.prepareStatement("INSERT INTO users (UserID, Username, Email, Password, Name, Surname, BirthDate, Affiliation) VALUES (?,?,?,?,?,?,?,?)");
- query.executeUpdate();
- return false;
- }*/
- public static Boolean userLogin(String username, String password) throws Exception {
- Boolean bool = null;
- try{
- Connection con = getConnection();
- PreparedStatement query = con.prepareStatement("SELECT * FROM users WHERE Username=? AND Password=?");
- query.setString(1, username);
- query.setString(2, password);
- ResultSet result = query.executeQuery();
- if(result.next()) {
- bool = true;
- }
- } catch(Exception e) {
- e.printStackTrace();
- }
- return bool;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement