Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Update a Konto
- public void updateKontoSaldo(Konto konto)
- {
- try (
- Connection connection = DriverManager.getConnection("jdbc:hsqldb:hsql://localhost:9001/mydb", "SA", "");
- PreparedStatement updateKonto = connection.prepareStatement("update konto set saldo = ? where kontonummer = ?");
- PreparedStatement findDataForCurrentKunde = connection.prepareStatement("select * from konto where kontonummer = ?");
- )
- {
- findDataForCurrentKunde.setInt(1, konto.getKontoNumber());
- ResultSet existingKonto = findDataForCurrentKunde.executeQuery();
- if (existingKonto.next())
- {
- updateKonto.setDouble(1, konto.getSaldo());
- updateKonto.setInt(2, konto.getKontoNumber());
- updateKonto.executeUpdate();
- }
- }
- catch (SQLException e)
- {
- System.out.println(e.getMessage());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement