T - the DataSource type being builtpublic final class DataSourceBuilder<T extends DataSource> extends Object
DataSource. Provides a limited subset of the
 properties supported by a typical DataSource as well as detection logic to pick
 the most suitable pooling DataSource implementation.
 
 The following pooling DataSource implementations are supported by this builder.
 When no type has been explicitly set, the first available pool
 implementation will be picked:
 
com.zaxxer.hikari.HikariDataSource)org.apache.tomcat.jdbc.pool.DataSource)org.apache.commons.dbcp2.BasicDataSource)oracle.ucp.jdbc.PoolDataSourceImpl)
 The following non-pooling DataSource implementations can be used when
 explicitly set as a type:
 
SimpleDriverDataSource
 (org.springframework.jdbc.datasource.SimpleDriverDataSource)oracle.jdbc.datasource.OracleDataSource)org.h2.jdbcx.JdbcDataSource)org.postgresql.ds.PGSimpleDataSource)DataSource implementation with appropriately named methods
 This class is commonly used in an @Bean method and often combined with
 @ConfigurationProperties.
create(), 
create(ClassLoader), 
derivedFrom(DataSource)| Modifier and Type | Method and Description | 
|---|---|
| T | build()Return a newly built  DataSourceinstance. | 
| static DataSourceBuilder<?> | create()Create a new  DataSourceBuilderinstance. | 
| static DataSourceBuilder<?> | create(ClassLoader classLoader)Create a new  DataSourceBuilderinstance. | 
| static DataSourceBuilder<?> | derivedFrom(DataSource dataSource)Create a new  DataSourceBuilderinstance derived from the specified data
 source. | 
| DataSourceBuilder<T> | driverClassName(String driverClassName)Set the driver class name that should be used when building the datasource. | 
| static Class<? extends DataSource> | findType(ClassLoader classLoader)Find the  DataSourcetype preferred for the given classloader. | 
| DataSourceBuilder<T> | password(String password)Set the password that should be used when building the datasource. | 
| <D extends DataSource> | type(Class<D> type)Set the  DataSourcetype that should be built. | 
| DataSourceBuilder<T> | url(String url)Set the URL that should be used when building the datasource. | 
| DataSourceBuilder<T> | username(String username)Set the username that should be used when building the datasource. | 
public <D extends DataSource> DataSourceBuilder<D> type(Class<D> type)
DataSource type that should be built.D - the datasource typetype - the datasource typepublic DataSourceBuilder<T> url(String url)
url - the JDBC urlpublic DataSourceBuilder<T> driverClassName(String driverClassName)
driverClassName - the driver class namepublic DataSourceBuilder<T> username(String username)
username - the user namepublic DataSourceBuilder<T> password(String password)
password - the passwordpublic T build()
DataSource instance.public static DataSourceBuilder<?> create()
DataSourceBuilder instance.public static DataSourceBuilder<?> create(ClassLoader classLoader)
DataSourceBuilder instance.classLoader - the classloader used to discover preferred settingsDataSource builder instancepublic static DataSourceBuilder<?> derivedFrom(DataSource dataSource)
DataSourceBuilder instance derived from the specified data
 source. The returned builder can be used to build the same type of
 DataSource with username, password, url and
 driverClassName properties copied from the original when not specifically
 set.dataSource - the source DataSourceDataSource builderpublic static Class<? extends DataSource> findType(ClassLoader classLoader)
DataSource type preferred for the given classloader.classLoader - the classloader used to discover preferred settingsDataSource type