本文整理了Java中org.sonar.db.Database
类的一些代码示例,展示了Database
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Database
类的具体详情如下:
包路径:org.sonar.db.Database
类名称:Database
暂无
代码示例来源:origin: SonarSource/sonarqube
private static Connection createDdlConnection(Database database) throws SQLException {
Connection res = database.getDataSource().getConnection();
res.setAutoCommit(false);
return res;
}
代码示例来源:origin: SonarSource/sonarqube
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 = "";
}
}
代码示例来源:origin: SonarSource/sonarqube
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);
}
代码示例来源:origin: SonarSource/sonarqube
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);
}
}
代码示例来源:origin: SonarSource/sonarqube
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);
代码示例来源:origin: SonarSource/sonarqube
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);
}
代码示例来源:origin: SonarSource/sonarqube
@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.");
}
}
代码示例来源:origin: SonarSource/sonarqube
private Connection createDdlConnection() throws SQLException {
Connection res = db.getDataSource().getConnection();
res.setAutoCommit(false);
return res;
}
代码示例来源:origin: org.sonarsource.sonarqube/sonar-db-migration
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);
}
}
代码示例来源:origin: SonarSource/sonarqube
@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);
}
代码示例来源:origin: SonarSource/sonarqube
public CleanupDisabledUsers(Database db, System2 system2) {
super(db);
this.falseValue = db.getDialect().getFalseSqlValue();
this.system2 = system2;
}
代码示例来源:origin: SonarSource/sonarqube
private Connection createDdlConnection() throws SQLException {
Connection writeConnection = db.getDataSource().getConnection();
writeConnection.setAutoCommit(false);
return writeConnection;
}
代码示例来源:origin: SonarSource/sonarqube
public UpdatePermissionTooLongTemplateKeys(Database db, UuidFactory uuidFactory) {
super(db);
this.uuidFactory = uuidFactory;
if (db.getDialect().getId().equals(MsSql.ID)) {
lengthFunction = "len";
} else {
lengthFunction = "length";
}
}
代码示例来源:origin: SonarSource/sonarqube
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;
}
代码示例来源:origin: SonarSource/sonarqube
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);
}
}
代码示例来源:origin: SonarSource/sonarqube
@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);
}
}
代码示例来源:origin: SonarSource/sonarqube
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;
}
代码示例来源:origin: SonarSource/sonarqube
public boolean tableExists(Database database) throws SQLException {
try (Connection connection = database.getDataSource().getConnection()) {
return DatabaseUtils.tableExists(tableName, connection);
}
}
代码示例来源:origin: SonarSource/sonarqube
/**
* 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);
}
代码示例来源:origin: SonarSource/sonarqube
private boolean tableExists() throws SQLException {
try (Connection connection = db.getDataSource().getConnection()) {
return DatabaseUtils.tableExists(ORG_QUALITY_GATES, connection);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!