From f55b348a559a1d3202493900f3d7885639b6c8f4 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Wed, 23 Mar 2016 20:54:55 +1300 Subject: [PATCH] #617 - Refactor - tidy up DataSource internals, reduce method visibility - markWithError() --- .../lib/sql/ExtendedPreparedStatement.java | 12 +++--- .../server/lib/sql/ExtendedStatement.java | 10 ++--- .../server/lib/sql/PooledConnection.java | 40 +++++++++---------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/sql/ExtendedPreparedStatement.java b/src/main/java/com/avaje/ebeaninternal/server/lib/sql/ExtendedPreparedStatement.java index aed648f43..75aeb60a5 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/sql/ExtendedPreparedStatement.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/sql/ExtendedPreparedStatement.java @@ -87,7 +87,7 @@ public class ExtendedPreparedStatement extends ExtendedStatement implements Prep } catch (SQLException e) { // we got an error... need to check this // connection before returning it - pooledConnection.addError(e); + pooledConnection.markWithError(); throw e; } } @@ -101,7 +101,7 @@ public class ExtendedPreparedStatement extends ExtendedStatement implements Prep } catch (SQLException e) { // we got an error... need to check // this connection before returning it - pooledConnection.addError(e); + pooledConnection.markWithError(); throw e; } } @@ -115,7 +115,7 @@ public class ExtendedPreparedStatement extends ExtendedStatement implements Prep } catch (SQLException e) { // we got an error... need to check // this connection before returning it - pooledConnection.addError(e); + pooledConnection.markWithError(); throw e; } } @@ -129,7 +129,7 @@ public class ExtendedPreparedStatement extends ExtendedStatement implements Prep } catch (SQLException e) { // we got an error... need to check // this connection before returning it - pooledConnection.addError(e); + pooledConnection.markWithError(); throw e; } } @@ -143,7 +143,7 @@ public class ExtendedPreparedStatement extends ExtendedStatement implements Prep } catch (SQLException e) { // we got an error... need to check // this connection before returning it - pooledConnection.addError(e); + pooledConnection.markWithError(); throw e; } } @@ -157,7 +157,7 @@ public class ExtendedPreparedStatement extends ExtendedStatement implements Prep } catch (SQLException e) { // we got an error... need to check // this connection before returning it - pooledConnection.addError(e); + pooledConnection.markWithError(); throw e; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/sql/ExtendedStatement.java b/src/main/java/com/avaje/ebeaninternal/server/lib/sql/ExtendedStatement.java index a18629bd6..ec2d484cd 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/sql/ExtendedStatement.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/sql/ExtendedStatement.java @@ -50,7 +50,7 @@ abstract class ExtendedStatement extends PreparedStatementDelegator { try { return pstmt.getConnection(); } catch (SQLException e) { - pooledConnection.addError(e); + pooledConnection.markWithError(); throw e; } } @@ -63,7 +63,7 @@ abstract class ExtendedStatement extends PreparedStatementDelegator { pooledConnection.setLastStatement(sql); pstmt.addBatch(sql); } catch (SQLException e) { - pooledConnection.addError(e); + pooledConnection.markWithError(); throw e; } } @@ -76,7 +76,7 @@ abstract class ExtendedStatement extends PreparedStatementDelegator { pooledConnection.setLastStatement(sql); return pstmt.execute(sql); } catch (SQLException e) { - pooledConnection.addError(e); + pooledConnection.markWithError(); throw e; } } @@ -89,7 +89,7 @@ abstract class ExtendedStatement extends PreparedStatementDelegator { pooledConnection.setLastStatement(sql); return pstmt.executeQuery(sql); } catch (SQLException e) { - pooledConnection.addError(e); + pooledConnection.markWithError(); throw e; } } @@ -102,7 +102,7 @@ abstract class ExtendedStatement extends PreparedStatementDelegator { pooledConnection.setLastStatement(sql); return pstmt.executeUpdate(sql); } catch (SQLException e) { - pooledConnection.addError(e); + pooledConnection.markWithError(); throw e; } } diff --git a/src/main/java/com/avaje/ebeaninternal/server/lib/sql/PooledConnection.java b/src/main/java/com/avaje/ebeaninternal/server/lib/sql/PooledConnection.java index 0dcd98928..2edbc9c02 100644 --- a/src/main/java/com/avaje/ebeaninternal/server/lib/sql/PooledConnection.java +++ b/src/main/java/com/avaje/ebeaninternal/server/lib/sql/PooledConnection.java @@ -324,7 +324,7 @@ public class PooledConnection extends ConnectionDelegator { try { return connection.createStatement(); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -337,7 +337,7 @@ public class PooledConnection extends ConnectionDelegator { return connection.createStatement(resultSetType, resultSetConcurreny); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -405,7 +405,7 @@ public class PooledConnection extends ConnectionDelegator { } } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -420,7 +420,7 @@ public class PooledConnection extends ConnectionDelegator { lastStatement = sql; return connection.prepareStatement(sql, resultSetType, resultSetConcurreny); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -446,7 +446,7 @@ public class PooledConnection extends ConnectionDelegator { * before it is placed back into the connection pool. *

*/ - void addError(Throwable throwable) { + void markWithError() { hadErrors = true; } @@ -633,7 +633,7 @@ public class PooledConnection extends ConnectionDelegator { resetIsolationReadOnlyRequired = true; connection.setTransactionIsolation(level); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -660,7 +660,7 @@ public class PooledConnection extends ConnectionDelegator { status = STATUS_ENDED; connection.commit(); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -753,7 +753,7 @@ public class PooledConnection extends ConnectionDelegator { status = STATUS_ENDED; connection.rollback(); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -765,7 +765,7 @@ public class PooledConnection extends ConnectionDelegator { try { connection.setAutoCommit(autoCommit); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -788,7 +788,7 @@ public class PooledConnection extends ConnectionDelegator { try { return connection.setSavepoint(); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -797,7 +797,7 @@ public class PooledConnection extends ConnectionDelegator { try { return connection.setSavepoint(savepointName); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -806,7 +806,7 @@ public class PooledConnection extends ConnectionDelegator { try { connection.rollback(sp); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -815,7 +815,7 @@ public class PooledConnection extends ConnectionDelegator { try { connection.releaseSavepoint(sp); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -824,7 +824,7 @@ public class PooledConnection extends ConnectionDelegator { try { connection.setHoldability(i); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -833,7 +833,7 @@ public class PooledConnection extends ConnectionDelegator { try { return connection.getHoldability(); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -842,7 +842,7 @@ public class PooledConnection extends ConnectionDelegator { try { return connection.createStatement(i, x, y); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -851,7 +851,7 @@ public class PooledConnection extends ConnectionDelegator { try { return connection.prepareStatement(s, i, x, y); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -860,7 +860,7 @@ public class PooledConnection extends ConnectionDelegator { try { return connection.prepareStatement(s, i); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -869,7 +869,7 @@ public class PooledConnection extends ConnectionDelegator { try { return connection.prepareStatement(s, s2); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } } @@ -878,7 +878,7 @@ public class PooledConnection extends ConnectionDelegator { try { return connection.prepareCall(s, i, x, y); } catch (SQLException ex) { - addError(ex); + markWithError(); throw ex; } }