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
connection.setAutoCommit(false); | |
connection.setSavepoint(); | |
try (PreparedStatement selectAccountStatementFrom = connection.prepareStatement(SELECT_ACCOUNT_BY_OWNER_SQL); | |
PreparedStatement selectAccountStatementTo = connection.prepareStatement(SELECT_ACCOUNT_BY_OWNER_SQL); | |
PreparedStatement updateAccountStatement = connection.prepareStatement(UPDATE_ACCOUNT_SQL)) { | |
ResultSet accountFrom = findAccount(bankTransfer.getFrom(), selectAccountStatementFrom); | |
ResultSet accountTo = findAccount(bankTransfer.getTo(), selectAccountStatementTo); | |
BigDecimal amount = bankTransfer.getAmount(); |
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
try (PreparedStatement selectAccountStatementFrom = connection.prepareStatement(SELECT_ACCOUNT_BY_OWNER_SQL); | |
PreparedStatement selectAccountStatementTo = connection.prepareStatement(SELECT_ACCOUNT_BY_OWNER_SQL); | |
PreparedStatement updateAccountStatement = connection.prepareStatement(UPDATE_ACCOUNT_SQL)) { | |
ResultSet accountFrom = findAccount(bankTransfer.getFrom(), selectAccountStatementFrom); | |
ResultSet accountTo = findAccount(bankTransfer.getTo(), selectAccountStatementTo); | |
BigDecimal amount = bankTransfer.getAmount(); | |
if (dataPresent(accountFrom, accountTo)) { | |
if (sufficientAccountBalance(amount, accountFrom)) { |
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
UPDATE employees | |
SET payment=payment + 500 |
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
SELECT locktype, mode, query FROM pg_locks pl | |
LEFT JOIN pg_stat_activity psa ON pl.pid = psa.pid | |
JOIN pg_class pc ON pc.oid = pl.relation | |
WHERE pc.relname = 'employees' |
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
VACUUM FULL employees; |
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
UPDATE employees | |
SET payment=payment + 500 | |
WHERE employeeid = 1; |
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
BEGIN; | |
SELECT xmin, xmax, employeeid, lastname, firstname, payment | |
FROM employees; |
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
BEGIN; | |
UPDATE employees | |
SET payment = payment + 1000 | |
WHERE employeeid = 1; |
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
SELECT xmin, xmax, employeeid, lastname, firstname, payment | |
FROM employees WHERE firstname = 'Carl'; |
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
COMMIT; |