Getting Started
Core
Relational Databases
NoSQL Databases
Cache
Internationalization
REST Client
Scheduler
Sendmail
Template
Virtual File Storage
Web
Testing
Advanced
Your application needs to connect to one or more databases? Void Framework is capable of handling multiple data sources at the same time through the use of DataSourceManager. It will provide all the necessary methods to obtain a connection from the desired data source. Each data source can be configured independently. Your application can, for example, be connected to PostgreSQL and Oracle at the same time.
Void Framework offers different implementations, depending on the implementation chosen, the configuration keys may change. Here you will find all the information to fully configure each implementation.
<dependency>
    <groupId>dev.voidframework</groupId>
    <artifactId>voidframework-datasource-c3p0</artifactId>
    <version>1.16.0</version>
</dependency>
<dependency>
    <groupId>dev.voidframework</groupId>
    <artifactId>voidframework-datasource-hikaricp</artifactId>
    <version>1.16.0</version>
</dependency>
The following configuration keys can be used in the configuration file of your application:
voidframework.datasource.default.driver the driver to be used to communicate with the database.voidframework.datasource.default.url the JDBC format URL to be used to reach the database.voidframework.datasource.default.username the username to be provided durint the authentication step.voidframework.datasource.default.password the password to be provided durint the authentication step.voidframework.datasource.default.statementCacheNumDeferredCloseThreads the number of threads to track when Connections are in use, and only destroy Statements when their parent Connections are not otherwise in use.voidframework.datasource.default.cachePrepStmts enable or disable the prepared statements cache.voidframework.datasource.default.prepStmtCacheSize the number of prepared statements cache to keep in the cache.voidframework.datasource.default.prepStmtCacheSqlLimit the size of the largest SQL query for which the parsing result will be keep in the cache.voidframework.datasource.default.autoCommit enable or disable the auto commit behavior when the connection goes back into the pool.voidframework.datasource.default.connectionInitSql the SQL statement that will be executed after every new connection.voidframework.datasource.default.connectionTestQuery the SQL statement that will be executed to test if the connection is still valid.voidframework.datasource.default.connectionTimeout the milliseconds to wait before timing out during the connection.voidframework.datasource.default.idleTimeout the milliseconds to wait before closing an unused connection.voidframework.datasource.default.keepaliveTime the milliseconds to wait before attempting to keep the connection alive.voidframework.datasource.default.minimumIdle the minimum number of alive connections in the pool.voidframework.datasource.default.maximumPoolSize the maximum number of connections allowed in the pool.voidframework.datasource.default.acquireIncrement determines how many connections at a time C3P0 will try to acquire when the pool is exhausted.voidframework.datasource.default.maxConnectionAge the milliseconds to wait before closing a connection.@Service
public class ExampleDataSourceService {
    private final Provider<DataSourceManager> dataSourceManagerProvider;
    @Inject
    public ExampleService(final Provider<DataSourceManager> dataSourceManagerProvider) {
        this.dataSourceManagerProvider = dataSourceManagerProvider;
    }
    public void example() throws SQLException {
      final Connection conn = dataSourceManagerProvider
          .get()
          .getConnection("default");
      /* ... */
      conn.close();
    }
}