Class BasicDataSourceProvider
java.lang.Object
org.mybatis.guice.datasource.dbcp.BasicDataSourceProvider
- All Implemented Interfaces:
jakarta.inject.Provider<DataSource>
public final class BasicDataSourceProvider
extends Object
implements jakarta.inject.Provider<DataSource>
Provides the Apache commons-dbcp
BasicDataSource
.-
Constructor Summary
ConstructorDescriptionBasicDataSourceProvider
(String driver, String url, ClassLoader driverClassLoader) Creates a new BasicDataSource using the needed parameter. -
Method Summary
Modifier and TypeMethodDescriptionget()
void
setAccessToUnderlyingConnectionAllowed
(boolean allow) Sets the access to underlying connection allowed.void
setAutoCommit
(boolean autoCommit) Sets the auto commit.void
setDefaultCatalog
(String defaultCatalog) Sets the default catalog.void
setDefaultReadOnly
(boolean defaultReadOnly) Sets the default read only.void
setDefaultTransactionIsolation
(int defaultTransactionIsolation) Sets the default transaction isolation.void
setDriverProperties
(Properties driverProperties) Sets the driver properties.void
setInitialSize
(int initialSize) Sets the initial size.void
setMaxIdle
(int maxIdle) Sets the max idle.void
setMaxOpenPreparedStatements
(int maxOpenPreparedStatements) Sets the max open prepared statements.void
setMaxTotal
(int maxTotal) Sets the max total.void
setMaxWaitMillis
(long maxWaitMillis) Sets the max wait in milliseconds.void
setMinEvictableIdleTimeMillis
(long minEvictableIdleTimeMillis) Sets the min evictable idle time millis.void
setMinIdle
(int minIdle) Sets the min idle.void
setNumTestsPerEvictionRun
(int numTestsPerEvictionRun) Sets the num tests per eviction run.void
setPassword
(String password) Sets the password.void
setPoolPreparedStatements
(boolean poolPreparedStatements) Sets the pool prepared statements.void
setTestOnBorrow
(boolean testOnBorrow) Sets the test on borrow.void
setTestOnReturn
(boolean testOnReturn) Sets the test on return.void
setTestWhileIdle
(boolean testWhileIdle) Sets the test while idle.void
setTimeBetweenEvictionRunsMillis
(int timeBetweenEvictionRunsMillis) Sets the time between eviction runs millis.void
Sets the user.void
setValidationQuery
(String validationQuery) Sets the validation query.
-
Constructor Details
-
BasicDataSourceProvider
@Inject public BasicDataSourceProvider(@Named("JDBC.driver") String driver, @Named("JDBC.url") String url, @Named("JDBC.driverClassLoader") ClassLoader driverClassLoader) Creates a new BasicDataSource using the needed parameter.- Parameters:
driver
- The JDBC driver class.url
- the database URL of the formjdbc:subprotocol:subname
.driverClassLoader
- ClassLoader to use to load JDBC driver class.
-
-
Method Details
-
setUser
Sets the user.- Parameters:
username
- the new user- Since:
- 3.3
-
setPassword
Sets the password.- Parameters:
password
- the new password- Since:
- 3.3
-
setAutoCommit
@Inject(optional=true) public void setAutoCommit(@Named("JDBC.autoCommit") boolean autoCommit) Sets the auto commit.- Parameters:
autoCommit
- the new auto commit
-
setDriverProperties
@Inject(optional=true) public void setDriverProperties(@Named("JDBC.driverProperties") Properties driverProperties) Sets the driver properties.- Parameters:
driverProperties
- the new driver properties
-
setAccessToUnderlyingConnectionAllowed
@Inject(optional=true) public void setAccessToUnderlyingConnectionAllowed(@Named("DBCP.accessToUnderlyingConnectionAllowed") boolean allow) Sets the access to underlying connection allowed.- Parameters:
allow
- the new access to underlying connection allowed
-
setDefaultCatalog
@Inject(optional=true) public void setDefaultCatalog(@Named("DBCP.defaultCatalog") String defaultCatalog) Sets the default catalog.- Parameters:
defaultCatalog
- the new default catalog
-
setDefaultReadOnly
@Inject(optional=true) public void setDefaultReadOnly(@Named("DBCP.defaultReadOnly") boolean defaultReadOnly) Sets the default read only.- Parameters:
defaultReadOnly
- the new default read only
-
setDefaultTransactionIsolation
@Inject(optional=true) public void setDefaultTransactionIsolation(@Named("DBCP.defaultTransactionIsolation") int defaultTransactionIsolation) Sets the default transaction isolation.- Parameters:
defaultTransactionIsolation
- the new default transaction isolation
-
setInitialSize
@Inject(optional=true) public void setInitialSize(@Named("DBCP.initialSize") int initialSize) Sets the initial size.- Parameters:
initialSize
- the new initial size
-
setMaxTotal
@Inject(optional=true) public void setMaxTotal(@Named("DBCP.maxTotal") int maxTotal) Sets the max total.- Parameters:
maxTotal
- the new max total
-
setMaxIdle
@Inject(optional=true) public void setMaxIdle(@Named("DBCP.maxIdle") int maxIdle) Sets the max idle.- Parameters:
maxIdle
- the new max idle
-
setMaxOpenPreparedStatements
@Inject(optional=true) public void setMaxOpenPreparedStatements(@Named("DBCP.maxOpenPreparedStatements") int maxOpenPreparedStatements) Sets the max open prepared statements.- Parameters:
maxOpenPreparedStatements
- the new max open prepared statements
-
setMaxWaitMillis
@Inject(optional=true) public void setMaxWaitMillis(@Named("DBCP.maxWaitMillis") long maxWaitMillis) Sets the max wait in milliseconds.- Parameters:
maxWaitMillis
- the new max wait in milliseconds
-
setMinEvictableIdleTimeMillis
@Inject(optional=true) public void setMinEvictableIdleTimeMillis(@Named("DBCP.minEvictableIdleTimeMillis") long minEvictableIdleTimeMillis) Sets the min evictable idle time millis.- Parameters:
minEvictableIdleTimeMillis
- the new min evictable idle time millis
-
setMinIdle
@Inject(optional=true) public void setMinIdle(@Named("DBCP.minIdle") int minIdle) Sets the min idle.- Parameters:
minIdle
- the new min idle
-
setNumTestsPerEvictionRun
@Inject(optional=true) public void setNumTestsPerEvictionRun(@Named("DBCP.numTestsPerEvictionRun") int numTestsPerEvictionRun) Sets the num tests per eviction run.- Parameters:
numTestsPerEvictionRun
- the new num tests per eviction run
-
setPoolPreparedStatements
@Inject(optional=true) public void setPoolPreparedStatements(@Named("DBCP.poolPreparedStatements") boolean poolPreparedStatements) Sets the pool prepared statements.- Parameters:
poolPreparedStatements
- the new pool prepared statements
-
setTestOnBorrow
@Inject(optional=true) public void setTestOnBorrow(@Named("DBCP.testOnBorrow") boolean testOnBorrow) Sets the test on borrow.- Parameters:
testOnBorrow
- the new test on borrow
-
setTestOnReturn
@Inject(optional=true) public void setTestOnReturn(@Named("DBCP.testOnReturn") boolean testOnReturn) Sets the test on return.- Parameters:
testOnReturn
- the new test on return
-
setTestWhileIdle
@Inject(optional=true) public void setTestWhileIdle(@Named("DBCP.testWhileIdle") boolean testWhileIdle) Sets the test while idle.- Parameters:
testWhileIdle
- the new test while idle
-
setTimeBetweenEvictionRunsMillis
@Inject(optional=true) public void setTimeBetweenEvictionRunsMillis(@Named("DBCP.timeBetweenEvictionRunsMillis") int timeBetweenEvictionRunsMillis) Sets the time between eviction runs millis.- Parameters:
timeBetweenEvictionRunsMillis
- the new time between eviction runs millis
-
setValidationQuery
@Inject(optional=true) public void setValidationQuery(@Named("DBCP.validationQuery") String validationQuery) Sets the validation query.- Parameters:
validationQuery
- the new validation query
-
get
- Specified by:
get
in interfacejakarta.inject.Provider<DataSource>
-