@Override protected void starting(Description description) { try { if (delegate == null || delegate.isClosed()) delegate = getNewConnection(); if (!autoCommit) delegate.setAutoCommit(false); } catch (Exception e) { throw new RuntimeException(e); } }
@Override protected void finished(Description description) { if (!autoCommit && delegate != null) { try { if (!delegate.isClosed()) { delegate.rollback(); delegate.reset(); } } catch (SQLException se) { throw new RuntimeException(se); } } }
@Override public PreparedStatement prepareStatement( String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return delegate.prepareStatement( sql, resultSetType, resultSetConcurrency, resultSetHoldability); }
@Override public Savepoint setSavepoint(String name) throws SQLException { return delegate.setSavepoint(name); }
@Override public PreparedStatement prepareStatement(String sql) throws SQLException { return delegate.prepareStatement(sql); }
private TestConnection getNewConnection() throws Exception { TestConnection conn = connPool.getConnection(userName, password); if (schema != null) conn.setSchema(schema); return conn; }
@Override public <T> T unwrap(Class<T> iface) throws SQLException { return delegate.unwrap(iface); }
@Override public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { delegate.setNetworkTimeout(executor, milliseconds); }
@Override public String getSchema() throws SQLException { return delegate.getSchema(); }
@Override public NClob createNClob() throws SQLException { return delegate.createNClob(); }
@Override public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { return delegate.prepareStatement(sql, columnNames); }
@Override public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { return delegate.prepareStatement(sql, autoGeneratedKeys); }
@Override public Statement createStatement( int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return delegate.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); }
@Override public void releaseSavepoint(Savepoint savepoint) throws SQLException { delegate.releaseSavepoint(savepoint); }
@Override public void rollback(Savepoint savepoint) throws SQLException { delegate.rollback(savepoint); }
@Override public Struct createStruct(String typeName, Object[] attributes) throws SQLException { return delegate.createStruct(typeName, attributes); }
@Override public void setSchema(String schema) throws SQLException { delegate.setSchema(schema); }
@Override public SQLXML createSQLXML() throws SQLException { return delegate.createSQLXML(); }
@Override public void abort(Executor executor) throws SQLException { delegate.abort(executor); }
@Override public boolean isValid(int timeout) throws SQLException { return delegate.isValid(timeout); }
@Override public int getNetworkTimeout() throws SQLException { return delegate.getNetworkTimeout(); }
@Override public void setClientInfo(String name, String value) throws SQLClientInfoException { delegate.setClientInfo(name, value); }
@Override public boolean isWrapperFor(Class<?> iface) throws SQLException { return delegate.isWrapperFor(iface); }
@Override public void setClientInfo(Properties properties) throws SQLClientInfoException { delegate.setClientInfo(properties); }
@Override public String getClientInfo(String name) throws SQLException { return delegate.getClientInfo(name); }
@Override public Properties getClientInfo() throws SQLException { return delegate.getClientInfo(); }
@Override public Statement createStatement() throws SQLException { return delegate.createStatement(); }
@Override public Array createArrayOf(String typeName, Object[] elements) throws SQLException { return delegate.createArrayOf(typeName, elements); }
@Override public CallableStatement prepareCall(String sql) throws SQLException { return delegate.prepareCall(sql); }
@Override public Savepoint setSavepoint() throws SQLException { return delegate.setSavepoint(); }