Class UnpooledDataSourceProvider

java.lang.Object
org.mybatis.guice.datasource.builtin.UnpooledDataSourceProvider
All Implemented Interfaces:
jakarta.inject.Provider<DataSource>

public final class UnpooledDataSourceProvider extends Object implements jakarta.inject.Provider<DataSource>
Provides the myBatis built-in UnpooledDataSource.
  • Constructor Details

    • UnpooledDataSourceProvider

      @Inject public UnpooledDataSourceProvider(@Named("JDBC.driver") String driver, @Named("JDBC.url") String url, @Named("JDBC.driverClassLoader") ClassLoader driverClassLoader)
      Creates a new UnpooledDataSource 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
    • setLoginTimeout

      @Inject(optional=true) public void setLoginTimeout(@Named("JDBC.loginTimeout") int loginTimeout)
      Sets the login timeout.
      Parameters:
      loginTimeout - the new login timeout
    • setDriverProperties

      @Inject(optional=true) public void setDriverProperties(@Named("JDBC.driverProperties") Properties driverProperties)
    • get

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