DataSourceBuilder
Convenience class for building a 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:
- Hikari (
com.zaxxer.hikari.HikariDataSource
) - Tomcat JDBC Pool (
org.apache.tomcat.jdbc.pool.DataSource
) - Apache DBCP2 (
org.apache.commons.dbcp2.BasicDataSource
) - Oracle UCP (
oracle.ucp.jdbc.PoolDataSourceImpl
) - C3P0 (
com.mchange.v2.c3p0.ComboPooledDataSource
)
The following non-pooling DataSource implementations can be used when explicitly set as a type:
- Spring's
SimpleDriverDataSource
(org.springframework.jdbc.datasource.SimpleDriverDataSource
) - Oracle (
oracle.jdbc.datasource.OracleDataSource
) - H2 (
org.h2.jdbcx.JdbcDataSource
) - Postgres (
org.postgresql.ds.PGSimpleDataSource
) - Any
DataSource
implementation with appropriately named methods
This class is commonly used in an @Bean
method and often combined with @ConfigurationProperties
.
Author
Dave Syer
Madhura Bhave
Fabio Grassi
Phillip Webb
Since
2.0.0
Parameters
<T>
the DataSource type being built
See also
Functions
Link copied to clipboard
Return a newly built DataSource instance.
Link copied to clipboard
Create a new DataSourceBuilder instance.
Link copied to clipboard
Create a new DataSourceBuilder instance derived from the specified data source.
Link copied to clipboard
Set the driver class name that should be used when building the datasource.
Link copied to clipboard
Find the DataSource type preferred for the given classloader.
Link copied to clipboard
Set the password that should be used when building the datasource.
Link copied to clipboard
Set the DataSource type that should be built.
Link copied to clipboard
Set the URL that should be used when building the datasource.
Link copied to clipboard
Set the username that should be used when building the datasource.