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 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 form jdbc:subprotocol:subname.
      driverClassLoader - ClassLoader to use to load JDBC driver class.
  • Method Details

    • setUser

      @Inject(optional=true) public void setUser(@Named("JDBC.username") String username)
      Sets the user.
      Parameters:
      username - the new user
      Since:
      3.3
    • setPassword

      @Inject(optional=true) public void setPassword(@Named("JDBC.password") String password)
      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

      public DataSource get()
      Specified by:
      get in interface jakarta.inject.Provider<DataSource>