本文整理了Java中org.sonar.db.Database.getDataSource()
方法的一些代码示例,展示了Database.getDataSource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Database.getDataSource()
方法的具体详情如下:
包路径:org.sonar.db.Database
类名称:Database
方法名:getDataSource
[英]Returns the configured datasource. Null as long as start() is not executed.
[中]返回配置的数据源。只要未执行start(),则为Null。
代码示例来源:origin: SonarSource/sonarqube
private static Connection createDdlConnection(Database database) throws SQLException {
Connection res = database.getDataSource().getConnection();
res.setAutoCommit(false);
return res;
}
代码示例来源:origin: SonarSource/sonarqube
private Connection createDdlConnection() throws SQLException {
Connection res = db.getDataSource().getConnection();
res.setAutoCommit(false);
return res;
}
代码示例来源:origin: SonarSource/sonarqube
private Connection createDdlConnection() throws SQLException {
Connection writeConnection = db.getDataSource().getConnection();
writeConnection.setAutoCommit(false);
return writeConnection;
}
代码示例来源: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
@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);
}
}
代码示例来源:origin: SonarSource/sonarqube
private BasicDataSource commonsDbcp() {
return (BasicDataSource) dbClient.getDatabase().getDataSource();
}
}
代码示例来源:origin: SonarSource/sonarqube
private boolean tableExists() throws SQLException {
try (Connection connection = db.getDataSource().getConnection()) {
return DatabaseUtils.tableExists(ORG_QUALITY_GATES, connection);
}
}
}
代码示例来源:origin: SonarSource/sonarqube
private boolean tableExists() throws SQLException {
try (Connection connection = db.getDataSource().getConnection()) {
return DatabaseUtils.tableExists(DEPRECATED_RULE_KEYS, connection);
}
}
}
代码示例来源: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
public boolean tableExists(Database database) throws SQLException {
try (Connection connection = database.getDataSource().getConnection()) {
return DatabaseUtils.tableExists(tableName, connection);
}
}
代码示例来源:origin: SonarSource/sonarqube
private boolean tableExists() throws SQLException {
try (Connection connection = getDatabase().getDataSource().getConnection()) {
return DatabaseUtils.tableExists(TABLE_NAME, connection);
}
}
}
代码示例来源:origin: SonarSource/sonarqube
private boolean tableExists() throws SQLException {
try (Connection connection = getDatabase().getDataSource().getConnection()) {
return DatabaseUtils.tableExists(TABLE_NAME, connection);
}
}
}
代码示例来源:origin: SonarSource/sonarqube
private boolean tableExists() throws SQLException {
try (Connection connection = getDatabase().getDataSource().getConnection()) {
return DatabaseUtils.tableExists(TABLE_NAME, connection);
}
}
}
代码示例来源:origin: SonarSource/sonarqube
private boolean tableExists() throws SQLException {
try (Connection connection = getDatabase().getDataSource().getConnection()) {
return DatabaseUtils.tableExists(TABLE_NAME, connection);
}
}
}
代码示例来源:origin: SonarSource/sonarqube
private boolean tableExists() throws SQLException {
try (Connection connection = getDatabase().getDataSource().getConnection()) {
return DatabaseUtils.tableExists(TABLE_NAME, connection);
}
}
}
代码示例来源: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
@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));
}
代码示例来源:origin: SonarSource/sonarqube
void truncateTables() {
try {
commands.truncateDatabase(db.getDataSource());
} catch (SQLException e) {
throw new IllegalStateException("Fail to truncate db tables", e);
}
}
代码示例来源:origin: SonarSource/sonarqube
@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));
}
代码示例来源:origin: SonarSource/sonarqube
private void insert(int... versions) throws SQLException {
try (Connection connection = dbTester.database().getDataSource().getConnection()) {
Arrays.stream(versions).forEach(version -> insert(connection, version));
}
}
内容来源于网络,如有侵权,请联系作者删除!