diff --git a/src/main/java/DAO/AccountDAO.java b/src/main/java/DAO/AccountDAO.java index f0112af..cf05f27 100644 --- a/src/main/java/DAO/AccountDAO.java +++ b/src/main/java/DAO/AccountDAO.java @@ -1,7 +1,6 @@ package DAO; import Model.Account; - import Util.ConnectionUtil; import java.sql.Connection; @@ -60,6 +59,26 @@ public Account findAccountByUsername(String username) { return null; } + public Account findAccountByAccountId(int account_id) { + try { + Connection conn = ConnectionUtil.getConnection(); + String sql = "SELECT username FROM account WHERE account_id = ?;"; + PreparedStatement ps = conn.prepareStatement(sql); + ps.setInt(1, account_id); + ResultSet rs = ps.executeQuery(); + while (rs.next()) { + Account account = new Account(); + String username = rs.getString(1); + account.setUsername(username); + account.setAccount_id(account_id); + return account; + } + } catch (SQLException e) { + e.printStackTrace(); + } + return null; + } + public List getAllAccounts() { List accounts = new ArrayList<>(); try {