Data Source Configuration #
DBPlusEngine-Driver supports all database JDBC drivers and connection pools.
Configuration Example #
The sample database driver is MySQL, and the connection pool is HikariCP, which can be replaced with other database drivers and connection pools.
Map<String, DataSource> dataSourceMap = new HashMap<>();
// Config the first data source
HikariDataSource dataSource1 = new HikariDataSource();
dataSource1.setDriverClassName("com.mysql.jdbc.Driver");
dataSource1.setJdbcUrl("jdbc:mysql://localhost:3306/ds_1");
dataSource1.setUsername("root");
dataSource1.setPassword("");
dataSourceMap.put("ds_1", dataSource1);
// Config the second data source
HikariDataSource dataSource2 = new HikariDataSource();
dataSource2.setDriverClassName("com.mysql.jdbc.Driver");
dataSource2.setJdbcUrl("jdbc:mysql://localhost:3306/ds_2");
dataSource2.setUsername("root");
dataSource2.setPassword("");
dataSourceMap.put("ds_2", dataSource2);
// Config other data source
...