Java 类org.springframework.boot.jdbc.DatabaseDriver 实例源码

项目:springboot-addon    文件:SpringBootJPASetupWizard.java   
@Override
public void validate(UIValidationContext validator)
{
   final DatabaseType database = dbType.getValue();
   final DatabaseDriver driver = DatabaseDriver.fromProductName(database.name());
   if (driver.equals(DatabaseDriver.UNKNOWN))
   {
      // Spring Boot doesn't know about this DB
      validator.addValidationError(dbType, "Spring Boot doesn't know about DB '" + dbType.getName() + "'");
   }

   if (isNotEmbeddedDB(database) && !databaseURL.hasValue() && !dataSourceName.hasValue())
   {
      validator.addValidationError(dataSourceName, "Either DataSource name or database URL is required");
      validator.addValidationError(databaseURL, "Either DataSource name or database URL is required");
   }
}
项目:orchestrator    文件:DatasourceConfig.java   
private XADataSource createXaDataSource(DataSourceProperties properties)
    throws ClassNotFoundException, LinkageError {
  String className = Optional
      .ofNullable(properties.getXa())
      .map(Xa::getDataSourceClassName)
      .map(String::trim)
      .map(Strings::emptyToNull)
      .orElseGet(() -> DatabaseDriver
          .fromJdbcUrl(properties.determineUrl())
          .getXaDataSourceClassName());
  Assert.state(StringUtils.hasLength(className),
      "No XA DataSource class name specified or inferred");
  XADataSource dataSource = createXaDataSourceInstance(className);
  bindXaProperties(dataSource, properties);
  return dataSource;
}
项目:spring-boot-multidatasource    文件:DataSourceConfiguration.java   
protected org.apache.tomcat.jdbc.pool.DataSource createTomcatDataSource(DataSourceProperties properties) {
    org.apache.tomcat.jdbc.pool.DataSource dataSource = createDataSource(
            properties, org.apache.tomcat.jdbc.pool.DataSource.class);
    DatabaseDriver databaseDriver = DatabaseDriver
            .fromJdbcUrl(properties.determineUrl());
    String validationQuery = databaseDriver.getValidationQuery();
    if (validationQuery != null) {
        dataSource.setTestOnBorrow(true);
        dataSource.setValidationQuery(validationQuery);
    }
    return dataSource; 
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DataSourceHealthIndicator.java   
protected String getValidationQuery(String product) {
    String query = this.query;
    if (!StringUtils.hasText(query)) {
        DatabaseDriver specific = DatabaseDriver.fromProductName(product);
        query = specific.getValidationQuery();
    }
    if (!StringUtils.hasText(query)) {
        query = DEFAULT_QUERY;
    }
    return query;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:XADataSourceAutoConfiguration.java   
private XADataSource createXaDataSource() {
    String className = this.properties.getXa().getDataSourceClassName();
    if (!StringUtils.hasLength(className)) {
        className = DatabaseDriver.fromJdbcUrl(this.properties.determineUrl())
                .getXaDataSourceClassName();
    }
    Assert.state(StringUtils.hasLength(className),
            "No XA DataSource class name specified");
    XADataSource dataSource = createXaDataSourceInstance(className);
    bindXaProperties(dataSource, this.properties);
    return dataSource;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DataSourceBuilder.java   
private void maybeGetDriverClassName() {
    if (!this.properties.containsKey("driverClassName")
            && this.properties.containsKey("url")) {
        String url = this.properties.get("url");
        String driverClass = DatabaseDriver.fromJdbcUrl(url).getDriverClassName();
        this.properties.put("driverClassName", driverClass);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DataSourceAutoConfigurationTests.java   
@Test
public void tomcatValidatesConnectionByDefault() {
    org.apache.tomcat.jdbc.pool.DataSource dataSource = autoConfigureDataSource(
            org.apache.tomcat.jdbc.pool.DataSource.class);
    assertThat(dataSource.isTestOnBorrow()).isTrue();
    assertThat(dataSource.getValidationQuery())
            .isEqualTo(DatabaseDriver.HSQLDB.getValidationQuery());
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DataSourceAutoConfigurationTests.java   
@Test
public void commonsDbcpValidatesConnectionByDefault() {
    BasicDataSource dataSource = autoConfigureDataSource(BasicDataSource.class,
            "org.apache.tomcat", "com.zaxxer.hikari");
    assertThat(dataSource.getTestOnBorrow()).isTrue();
    assertThat(dataSource.getValidationQuery())
            .isEqualTo(DatabaseDriver.HSQLDB.getValidationQuery());
}
项目:spring-boot-concourse    文件:DataSourceHealthIndicator.java   
protected String getValidationQuery(String product) {
    String query = this.query;
    if (!StringUtils.hasText(query)) {
        DatabaseDriver specific = DatabaseDriver.fromProductName(product);
        query = specific.getValidationQuery();
    }
    if (!StringUtils.hasText(query)) {
        query = DEFAULT_QUERY;
    }
    return query;
}
项目:spring-boot-concourse    文件:XADataSourceAutoConfiguration.java   
private XADataSource createXaDataSource() {
    String className = this.properties.getXa().getDataSourceClassName();
    if (!StringUtils.hasLength(className)) {
        className = DatabaseDriver.fromJdbcUrl(this.properties.determineUrl())
                .getXaDataSourceClassName();
    }
    Assert.state(StringUtils.hasLength(className),
            "No XA DataSource class name specified");
    XADataSource dataSource = createXaDataSourceInstance(className);
    bindXaProperties(dataSource, this.properties);
    return dataSource;
}
项目:spring-boot-concourse    文件:DataSourceBuilder.java   
private void maybeGetDriverClassName() {
    if (!this.properties.containsKey("driverClassName")
            && this.properties.containsKey("url")) {
        String url = this.properties.get("url");
        String driverClass = DatabaseDriver.fromJdbcUrl(url).getDriverClassName();
        this.properties.put("driverClassName", driverClass);
    }
}
项目:spring-boot-concourse    文件:DataSourceAutoConfigurationTests.java   
@Test
public void tomcatValidatesConnectionByDefault() {
    org.apache.tomcat.jdbc.pool.DataSource dataSource = autoConfigureDataSource(
            org.apache.tomcat.jdbc.pool.DataSource.class);
    assertThat(dataSource.isTestOnBorrow()).isTrue();
    assertThat(dataSource.getValidationQuery())
            .isEqualTo(DatabaseDriver.HSQLDB.getValidationQuery());
}
项目:spring-boot-concourse    文件:DataSourceAutoConfigurationTests.java   
@Test
public void commonsDbcpValidatesConnectionByDefault() {
    BasicDataSource dataSource = autoConfigureDataSource(BasicDataSource.class,
            "org.apache.tomcat", "com.zaxxer.hikari");
    assertThat(dataSource.getTestOnBorrow()).isTrue();
    assertThat(dataSource.getValidationQuery())
            .isEqualTo(DatabaseDriver.HSQLDB.getValidationQuery());
}
项目:sample-boot-micro    文件:OrmDataSourceProperties.java   
private String driverClassName() {
    if (StringUtils.hasText(driverClassName)) {
        return driverClassName;
    }
    return DatabaseDriver.fromJdbcUrl(url).getDriverClassName();
}
项目:sample-boot-micro    文件:OrmDataSourceProperties.java   
private String validationQuery() {
    if (StringUtils.hasText(validationQuery)) {
        return validationQuery;
    }
    return DatabaseDriver.fromJdbcUrl(url).getValidationQuery();
}
项目:sample-boot-hibernate    文件:OrmDataSourceProperties.java   
private String driverClassName() {
    if (StringUtils.hasText(driverClassName)) {
        return driverClassName;
    }
    return DatabaseDriver.fromJdbcUrl(url).getDriverClassName();
}
项目:sample-boot-hibernate    文件:OrmDataSourceProperties.java   
private String validationQuery() {
    if (StringUtils.hasText(validationQuery)) {
        return validationQuery;
    }
    return DatabaseDriver.fromJdbcUrl(url).getValidationQuery();
}