File tree Expand file tree Collapse file tree
src/main/java/com/softwareverde/database/transaction Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11group ' com.softwareverde'
2- version ' 4 .0.0'
2+ version ' 3 .0.0'
33
44apply plugin : ' java'
55
Original file line number Diff line number Diff line change 11package com .softwareverde .database .transaction ;
22
3- import com .softwareverde .database .Database ;
43import com .softwareverde .database .DatabaseConnection ;
4+ import com .softwareverde .database .DatabaseConnectionFactory ;
55import com .softwareverde .database .DatabaseException ;
66
77import java .sql .Connection ;
8- import java .sql .SQLException ;
98
109public class JdbcDatabaseTransaction implements DatabaseTransaction <Connection > {
11- protected final Database <Connection > _database ;
10+ protected final DatabaseConnectionFactory <Connection > _databaseConnectionFactory ;
1211
13- public JdbcDatabaseTransaction (final Database <Connection > database ) {
14- _database = database ;
12+ public JdbcDatabaseTransaction (final DatabaseConnectionFactory <Connection > databaseConnectionFactory ) {
13+ _databaseConnectionFactory = databaseConnectionFactory ;
1514 }
1615
1716 @ Override
1817 public void execute (final DatabaseRunnable <Connection > databaseConnectedRunnable ) throws DatabaseException {
19- try (final DatabaseConnection <Connection > databaseConnection = _database .newConnection ()) {
18+ try (final DatabaseConnection <Connection > databaseConnection = _databaseConnectionFactory .newConnection ()) {
2019 final Connection connection = databaseConnection .getRawConnection (); // Should be closed for us by DatabaseConnection.close()
2120
2221 try {
2322 connection .setAutoCommit (false );
2423 databaseConnectedRunnable .run (databaseConnection );
2524 connection .commit ();
2625 }
27- catch (final SQLException sqlException ) {
26+ catch (final Exception exception ) {
2827 connection .rollback ();
29- throw sqlException ;
28+ throw exception ;
3029 }
3130
3231 }
You can’t perform that action at this time.
0 commit comments