Last active
January 24, 2023 18:34
-
-
Save kubawieczorek/6bfe3e38100ea94329677a30471a1966 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Statement statement = connection.createStatement()) { | |
List<BankAccount> accountList = new ArrayList<>(); | |
ResultSet resultSet = statement.executeQuery("SELECT * FROM accounts"); | |
while (resultSet.next()) { | |
BankAccount bankAccount = new BankAccount(); | |
bankAccount.setBalance(resultSet.getBigDecimal("balance")); | |
bankAccount.setOwner(resultSet.getString("owner")); | |
accountList.add(bankAccount); | |
} | |
return accountList; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment