org.springframework.boot.jdbc.DatabaseDriver Java Examples
The following examples show how to use
org.springframework.boot.jdbc.DatabaseDriver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CasbinAutoConfiguration.java From casbin-spring-boot-starter with Apache License 2.0 | 7 votes |
/** * 获取当前使用数据库类型 */ private static String getDatabaseName(DataSource dataSource) { try { String productName = JdbcUtils. commonDatabaseName(JdbcUtils.extractDatabaseMetaData( dataSource, "getDatabaseProductName" ).toString()); DatabaseDriver databaseDriver = DatabaseDriver.fromProductName(productName); if (databaseDriver == DatabaseDriver.UNKNOWN) { throw new IllegalStateException("Unable to detect database type"); } return databaseDriver.getId(); } catch (MetaDataAccessException ex) { throw new IllegalStateException("Unable to detect database type", ex); } }
Example #2
Source File: SkipperFlywayConfigurationCustomizer.java From spring-cloud-skipper with Apache License 2.0 | 6 votes |
@Override public void customize(FluentConfiguration configuration) { // boot's flyway auto-config doesn't allow to define callbacks per // vendor id, so essentially customizing those here. DataSource dataSource = configuration.getDataSource(); DatabaseDriver databaseDriver = getDatabaseDriver(dataSource); logger.info("Customizing flyway config, detected DatabaseDriver as {}.", databaseDriver); if (databaseDriver == DatabaseDriver.POSTGRESQL) { configuration.callbacks(new PostgresBeforeBaseline()); } else if (databaseDriver == DatabaseDriver.MYSQL || databaseDriver == DatabaseDriver.MARIADB) { configuration.callbacks(new MysqlBeforeBaseline()); } else if (databaseDriver == DatabaseDriver.SQLSERVER) { configuration.callbacks(new MsSqlBeforeBaseline()); } else if (databaseDriver == DatabaseDriver.ORACLE) { configuration.callbacks(new OracleBeforeBaseline()); } else if (databaseDriver == DatabaseDriver.DB2) { configuration.callbacks(new Db2BeforeBaseline()); } }
Example #3
Source File: DataFlowFlywayConfigurationCustomizer.java From spring-cloud-dataflow with Apache License 2.0 | 6 votes |
@Override public void customize(FluentConfiguration configuration) { // boot's flyway auto-config doesn't allow to define callbacks per // vendor id, so essentially customizing those here. DataSource dataSource = configuration.getDataSource(); DatabaseDriver databaseDriver = getDatabaseDriver(dataSource); if (databaseDriver == DatabaseDriver.POSTGRESQL) { configuration.callbacks(new PostgresBeforeBaseline()); } else if (databaseDriver == DatabaseDriver.MYSQL || databaseDriver == DatabaseDriver.MARIADB) { configuration.callbacks(new MysqlBeforeBaseline()); } else if (databaseDriver == DatabaseDriver.SQLSERVER) { configuration.callbacks(new MsSqlBeforeBaseline()); } else if (databaseDriver == DatabaseDriver.ORACLE) { configuration.callbacks(new OracleBeforeBaseline()); } else if (databaseDriver == DatabaseDriver.DB2) { configuration.callbacks(new Db2BeforeBaseline()); } }
Example #4
Source File: SkipperFlywayConfigurationCustomizer.java From spring-cloud-skipper with Apache License 2.0 | 5 votes |
private DatabaseDriver getDatabaseDriver(DataSource dataSource) { // copied from boot's flyway auto-config to get matching db vendor id try { String url = JdbcUtils.extractDatabaseMetaData(dataSource, "getURL"); return DatabaseDriver.fromJdbcUrl(url); } catch (MetaDataAccessException ex) { throw new IllegalStateException(ex); } }
Example #5
Source File: XADataSourceBuilder.java From teiid-spring-boot with Apache License 2.0 | 5 votes |
public String dataSourceClassName() { String className = this.properties.get("dataSourceClassName"); if (!StringUtils.hasLength(className)) { String url = this.properties.get("url"); className = DatabaseDriver.fromJdbcUrl(url).getXaDataSourceClassName(); } return className; }
Example #6
Source File: DataFlowFlywayConfigurationCustomizer.java From spring-cloud-dataflow with Apache License 2.0 | 5 votes |
private DatabaseDriver getDatabaseDriver(DataSource dataSource) { // copied from boot's flyway auto-config to get matching db vendor id try { String url = JdbcUtils.extractDatabaseMetaData(dataSource, "getURL"); return DatabaseDriver.fromJdbcUrl(url); } catch (MetaDataAccessException ex) { throw new IllegalStateException(ex); } }
Example #7
Source File: OrmDataSourceProperties.java From sample-boot-micro with MIT License | 4 votes |
private String driverClassName() { if (StringUtils.hasText(driverClassName)) { return driverClassName; } return DatabaseDriver.fromJdbcUrl(url).getDriverClassName(); }
Example #8
Source File: OrmDataSourceProperties.java From sample-boot-micro with MIT License | 4 votes |
private String validationQuery() { if (StringUtils.hasText(validationQuery)) { return validationQuery; } return DatabaseDriver.fromJdbcUrl(url).getValidationQuery(); }