private static Connection createDdlConnection(Database database) throws SQLException { Connection res = database.getDataSource().getConnection(); res.setAutoCommit(false); return res; }
public FixMissingQualityProfilesOnOrganizations(Database db, System2 system2, UuidFactory uuidFactory, Configuration configuration) { super(db); this.system2 = system2; this.uuidFactory = uuidFactory; this.configuration = configuration; if (db.getDialect().getId().equals(MySql.ID) || db.getDialect().getId().equals(MsSql.ID)) { as = " AS "; } else { as = ""; } }
public void changeLevel(LoggerLevel level) { Level logbackLevel = Level.toLevel(level.name()); database.enableSqlLogging(level == TRACE); helper.changeRoot(serverProcessLogging.getLogLevelConfig(), logbackLevel); LoggerFactory.getLogger(ServerLogging.class).info("Level of logs changed to {}", level); }
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); } }
db = new H2Database("h2Tests" + DigestUtils.md5Hex(StringUtils.defaultString(schemaPath)), schemaPath == null); db.start(); if (schemaPath != null) { if (db.getDialect().getId().equals("h2")) { ((H2Database) db).executeScript(schemaPath); } else { db.stop(); LOG.debug("Test Database: " + db); commands = DatabaseCommands.forDialect(db.getDialect()); tester = new DataSourceDatabaseTester(db.getDataSource(), commands.useLoginAsSchema() ? login : null);
MyBatisConfBuilder(Database database) { this.conf = new Configuration(); this.conf.setEnvironment(new Environment("production", createTransactionFactory(), database.getDataSource())); this.conf.setUseGeneratedKeys(true); this.conf.setLazyLoadingEnabled(false); this.conf.setJdbcTypeForNull(JdbcType.NULL); Dialect dialect = database.getDialect(); this.conf.setDatabaseId(dialect.getId()); this.conf.getVariables().setProperty("_true", dialect.getTrueSqlValue()); this.conf.getVariables().setProperty("_false", dialect.getFalseSqlValue()); this.conf.getVariables().setProperty("_from_dual", dialect.getSqlFromDual()); this.conf.getVariables().setProperty("_scrollFetchSize", String.valueOf(dialect.getScrollDefaultFetchSize())); this.conf.setLocalCacheScope(LocalCacheScope.STATEMENT); }
@Override public void start() { if (MySql.ID.equals(database.getDialect().getId())) { throw new IllegalStateException("MySQL is not supported for Data Center Edition. Please connect to a supported database: Oracle, PostgreSQL, Microsoft SQL Server."); } }
private Connection createDdlConnection() throws SQLException { Connection res = db.getDataSource().getConnection(); res.setAutoCommit(false); return res; }
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); } }
@Test public void changeLevel_to_trace_enables_db_logging() { LogLevelConfig logLevelConfig = LogLevelConfig.newBuilder(rootLoggerName).build(); when(serverProcessLogging.getLogLevelConfig()).thenReturn(logLevelConfig); reset(database); underTest.changeLevel(INFO); verify(database).enableSqlLogging(false); reset(database); underTest.changeLevel(DEBUG); verify(database).enableSqlLogging(false); reset(database); underTest.changeLevel(TRACE); verify(database).enableSqlLogging(true); }
public CleanupDisabledUsers(Database db, System2 system2) { super(db); this.falseValue = db.getDialect().getFalseSqlValue(); this.system2 = system2; }
private Connection createDdlConnection() throws SQLException { Connection writeConnection = db.getDataSource().getConnection(); writeConnection.setAutoCommit(false); return writeConnection; }
public UpdatePermissionTooLongTemplateKeys(Database db, UuidFactory uuidFactory) { super(db); this.uuidFactory = uuidFactory; if (db.getDialect().getId().equals(MsSql.ID)) { lengthFunction = "len"; } else { lengthFunction = "length"; } }
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; }
public static SelectImpl create(Database db, Connection connection, String sql) throws SQLException { // TODO use DbClient#newScrollingSelectStatement() PreparedStatement pstmt = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); pstmt.setFetchSize(db.getDialect().getScrollDefaultFetchSize()); return new SelectImpl(pstmt); } }
@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); } }
private String createTruncateSql(String table) { if (dbClient.getDatabase().getDialect().getId().equals(Oracle.ID)) { // truncate operation is needs to lock the table on Oracle. Unfortunately // it fails sometimes in our QA environment because table is locked. // We never found the root cause (no locks found when displaying them just after // receiving the error). // Workaround is to use "delete" operation. It does not require lock on table. return "DELETE FROM " + table; } return "TRUNCATE TABLE " + table; }
public boolean tableExists(Database database) throws SQLException { try (Connection connection = database.getDataSource().getConnection()) { return DatabaseUtils.tableExists(tableName, connection); } }
/** * Create a PreparedStatement for SELECT requests with scrolling of results */ public PreparedStatement newScrollingSelectStatement(DbSession session, String sql) { int fetchSize = database.getDialect().getScrollDefaultFetchSize(); return newScrollingSelectStatement(session, sql, fetchSize); }
private boolean tableExists() throws SQLException { try (Connection connection = db.getDataSource().getConnection()) { return DatabaseUtils.tableExists(ORG_QUALITY_GATES, connection); } } }