@Override public Connection getConnection() throws SQLException { return targetStatement.getConnection(); }
@Override public Connection getConnection() throws SQLException { return statement.getConnection(); }
public Builder(Statement statement) throws SQLException { this.statement = statement; this.connection = statement.getConnection(); }
@Override public Connection getConnection() throws SQLException { return delegate.getConnection(); }
public StatementExecuteUnit(final RouteUnit routeUnit, final Statement statement, final ConnectionMode connectionMode) throws SQLException { this.routeUnit = routeUnit; this.statement = statement; this.connectionMode = connectionMode; this.databaseMetaData = statement.getConnection().getMetaData(); } }
private static void validateServerVersion(Statement statement) throws SQLException { DatabaseMetaData metaData = statement.getConnection().getMetaData(); int majorVersion = metaData.getDatabaseMajorVersion(); int minorVersion = metaData.getDatabaseMinorVersion(); if (majorVersion < 9 || (majorVersion == 9 && minorVersion < 4)) { throw new SQLException("Cannot connect to a version of Postgres lower than 9.4"); } }
@Override public Connection statement_getConnection(StatementProxy statement) throws SQLException { if (this.pos < filterSize) { return nextFilter().statement_getConnection(this, statement); } return statement.getRawObject().getConnection(); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.getConnection().close(); stmt.close(); assert stmt.isClosed(); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.getConnection().close(); stmt.close(); assert stmt.isClosed(); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.getConnection().close(); stmt.close(); assert stmt.isClosed(); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.getConnection().close(); stmt.close(); assert stmt.isClosed(); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.getConnection().close(); stmt.close(); assert stmt.isClosed(); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.getConnection().close(); stmt.close(); assert stmt.isClosed(); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.getConnection().close(); stmt.close(); assert stmt.isClosed(); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.getConnection().close(); stmt.close(); assert stmt.isClosed(); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.getConnection().close(); stmt.close(); assert stmt.isClosed(); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.getConnection().close(); stmt.close(); assert stmt.isClosed(); } }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { if (stmt != null) { stmt.getConnection().close(); stmt.close(); assertTrue(stmt.isClosed()); } }
@Test public void testExecuteQueryWarnings() throws SQLException { try (ResultSet rs = statement.executeQuery("SELECT a FROM (VALUES 1, 2, 3) t(a)")) { assertNull(statement.getConnection().getWarnings()); assertNull(statement.getWarnings()); assertNull(rs.getWarnings()); Set<WarningEntry> currentWarnings = new HashSet<>(); while (rs.next()) { assertWarnings(rs.getWarnings(), currentWarnings); } TestingWarningCollectorConfig warningCollectorConfig = new TestingWarningCollectorConfig().setPreloadedWarnings(PRELOADED_WARNINGS).setAddWarnings(true); TestingWarningCollector warningCollector = new TestingWarningCollector(new WarningCollectorConfig(), warningCollectorConfig); List<PrestoWarning> expectedWarnings = warningCollector.getWarnings(); for (PrestoWarning prestoWarning : expectedWarnings) { assertTrue(currentWarnings.contains(new WarningEntry(new PrestoSqlWarning(prestoWarning)))); } } }
@Before public void setup() throws Exception { this.connection = mock(Connection.class); this.dataSource = mock(DataSource.class); this.preparedStatement = mock(PreparedStatement.class); this.statement = mock(Statement.class); this.resultSet = mock(ResultSet.class); this.template = new JdbcTemplate(this.dataSource); this.callableStatement = mock(CallableStatement.class); given(this.dataSource.getConnection()).willReturn(this.connection); given(this.connection.prepareStatement(anyString())).willReturn(this.preparedStatement); given(this.preparedStatement.executeQuery()).willReturn(this.resultSet); given(this.preparedStatement.executeQuery(anyString())).willReturn(this.resultSet); given(this.preparedStatement.getConnection()).willReturn(this.connection); given(this.statement.getConnection()).willReturn(this.connection); given(this.statement.executeQuery(anyString())).willReturn(this.resultSet); given(this.connection.prepareCall(anyString())).willReturn(this.callableStatement); given(this.callableStatement.getResultSet()).willReturn(this.resultSet); }