Skip to content
Snippets Groups Projects
Commit 07e13305 authored by Goik Martin's avatar Goik Martin
Browse files

Allow for configurable isolation level

parent 5455539f
No related branches found
No related tags found
No related merge requests found
package de.hdm_stuttgart.mi.sda2.account;
import java.sql.Connection;
import java.sql.SQLException;
import javafx.application.Application;
......@@ -69,7 +70,7 @@ public class TransferDriver extends Application {
@Override
public void start(final Stage primaryStage) throws SQLException {
dbh.connect();
dbh.connect(Connection.TRANSACTION_SERIALIZABLE);
primaryStage.setTitle("Account transfer!");
......
......@@ -21,14 +21,14 @@ public class DbHandler {
return Conf.get("DbHandler.user") + '@' + Conf.get("DbHandler.jdbcUrl");
}
public boolean connect() {
public boolean connect(final int isolationLevel) {
try {
conn = DriverManager.getConnection(
Conf.get("DbHandler.jdbcUrl"),
Conf.get("DbHandler.user"),
Conf.get("DbHandler.password"));
conn.setAutoCommit(false);
conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
conn.setTransactionIsolation(isolationLevel);
updateAccount = conn.prepareStatement("UPDATE Account SET balance = balance + ? WHERE number = ?");
log.info("Connection '" + getConnectionName() + "' established" );
return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment