private static Connection createDdlConnection(Database database) throws SQLException { Connection res = database.getDataSource().getConnection(); res.setAutoCommit(false); return res; }
private Connection createDdlConnection() throws SQLException { Connection res = db.getDataSource().getConnection(); res.setAutoCommit(false); return res; }
private Connection createDdlConnection() throws SQLException { Connection writeConnection = db.getDataSource().getConnection(); writeConnection.setAutoCommit(false); return writeConnection; }
private Connection createReadUncommittedConnection() throws SQLException { Connection connection = db.getDataSource().getConnection(); connection.setAutoCommit(false); if (connection.getMetaData().supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED)) { connection.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED); } return connection; }
@Override public Optional<Long> getLastMigrationNumber() { try (Connection connection = database.getDataSource().getConnection()) { List<Long> versions = selectVersions(connection); if (!versions.isEmpty()) { return Optional.of(versions.get(versions.size() - 1)); } return Optional.empty(); } catch (SQLException e) { throw new IllegalStateException("Failed to read content of table " + SCHEMA_MIGRATIONS_TABLE, e); } }
private BasicDataSource commonsDbcp() { return (BasicDataSource) dbClient.getDatabase().getDataSource(); } }
private boolean tableExists() throws SQLException { try (Connection connection = db.getDataSource().getConnection()) { return DatabaseUtils.tableExists(ORG_QUALITY_GATES, connection); } } }
private boolean tableExists() throws SQLException { try (Connection connection = db.getDataSource().getConnection()) { return DatabaseUtils.tableExists(DEPRECATED_RULE_KEYS, connection); } } }
@Override public void start() { try (Connection connection = database.getDataSource().getConnection()) { checkState(DatabaseUtils.tableExists(MigrationHistoryTable.NAME, connection), "Migration history table is missing"); } catch (SQLException e) { Throwables.propagate(e); } }
public boolean tableExists(Database database) throws SQLException { try (Connection connection = database.getDataSource().getConnection()) { return DatabaseUtils.tableExists(tableName, connection); } }
private boolean tableExists() throws SQLException { try (Connection connection = getDatabase().getDataSource().getConnection()) { return DatabaseUtils.tableExists(TABLE_NAME, connection); } } }
private boolean tableExists() throws SQLException { try (Connection connection = getDatabase().getDataSource().getConnection()) { return DatabaseUtils.tableExists(TABLE_NAME, connection); } } }
private boolean tableExists() throws SQLException { try (Connection connection = getDatabase().getDataSource().getConnection()) { return DatabaseUtils.tableExists(TABLE_NAME, connection); } } }
private boolean tableExists() throws SQLException { try (Connection connection = getDatabase().getDataSource().getConnection()) { return DatabaseUtils.tableExists(TABLE_NAME, connection); } } }
private boolean tableExists() throws SQLException { try (Connection connection = getDatabase().getDataSource().getConnection()) { return DatabaseUtils.tableExists(TABLE_NAME, connection); } } }
public void check(State state) { try (Connection connection = db.getDataSource().getConnection()) { CharsetHandler handler = getHandler(db.getDialect()); if (handler != null) { handler.handle(connection, state); } } catch (SQLException e) { throw new IllegalStateException(e); } }
@Before public void setUp() throws Exception { DataSource dataSource = mock(DataSource.class); when(database.getDataSource()).thenReturn(dataSource); Connection connection = mock(Connection.class); when(dataSource.getConnection()).thenReturn(connection); when(connection.getMetaData()).thenReturn(mock(DatabaseMetaData.class)); }
void truncateTables() { try { commands.truncateDatabase(db.getDataSource()); } catch (SQLException e) { throw new IllegalStateException("Fail to truncate db tables", e); } }
@Before public void setUp() throws Exception { DataSource dataSource = mock(DataSource.class); when(database.getDataSource()).thenReturn(dataSource); Connection connection = mock(Connection.class); when(dataSource.getConnection()).thenReturn(connection); when(connection.getMetaData()).thenReturn(mock(DatabaseMetaData.class)); }
private void insert(int... versions) throws SQLException { try (Connection connection = dbTester.database().getDataSource().getConnection()) { Arrays.stream(versions).forEach(version -> insert(connection, version)); } }