Package database.dao

Class AccountDAO

java.lang.Object
database.dao.AccountDAO
All Implemented Interfaces:
IAccountDAO

public class AccountDAO extends Object implements IAccountDAO
AccountDAO class for the game Contains methods for saving and retrieving accounts from the database
  • Constructor Details

    • AccountDAO

      public AccountDAO()
  • Method Details

    • saveAccount

      public boolean saveAccount(Account account)
      Saves an account to the database
      Specified by:
      saveAccount in interface IAccountDAO
      Parameters:
      account - Account-object to be saved
      Returns:
      true if successful, false if not
    • getAccount

      public Account getAccount(Long id)
      finds an account by id
      Specified by:
      getAccount in interface IAccountDAO
      Parameters:
      id - account id
      Returns:
      Account-object
    • getAccountByNameAndPassword

      public Account getAccountByNameAndPassword(String username, String password)
      finds an account by name and password
      Specified by:
      getAccountByNameAndPassword in interface IAccountDAO
      Parameters:
      username - account name
      password - account password
      Returns:
      Account-object
    • getAccountByName

      public Account getAccountByName(String username)
      finds an account by name
      Specified by:
      getAccountByName in interface IAccountDAO
      Parameters:
      username - account name
      Returns:
      Account-object
    • getAllAccounts

      public ArrayList<Account> getAllAccounts()
      finds all accounts
      Specified by:
      getAllAccounts in interface IAccountDAO
      Returns:
      ArrayList of Account-objects
    • deleteAccount

      public boolean deleteAccount(Long id)
      deletes an account by id
      Specified by:
      deleteAccount in interface IAccountDAO
      Parameters:
      id - account id
      Returns:
      true if successful, false if not
    • passwordHasher

      public void passwordHasher()
      converts plaintext password to hashes run this once and never again

      checks if password is under certain length (40 chars) and hashes the password if it is hashes seem to be 45 chars long so this should work ¯\_(ツ)_/¯

      Specified by:
      passwordHasher in interface IAccountDAO