Common module for SQL database plugin
| Actframework version | act-sql-common version |
|---|---|
| 1.1.0 | 1.0.0 |
| 1.1.1 | 1.0.1 |
Specifies the jdbc url of the datasource.
Default value: jdbc:h2:./test if h2 jdbc driver is provided, otherwise it will break the application from bootstrap.
Optionally. Specifies the jdbc driver class. If not specified the framework will infer the driver class from the url
Specifies the jdbc connection username
Default value: sa
Specifies the jdbc connection password
Default value: empty string
Specifies the DataSourceProvider implementation.
About value and default value:
- if
hikarifound in the value then it will use theact.db.sql.datasource.HikariDataSourceProvider - otherwise if
druidfound in the value then it will use theact.db.sql.datasource.DruidDataSourceProvider - otherwise if the value starts with
shared:then it will try to extract thedbIdfrom the value, e.g. if value isshared:ds1then thedbIdisds1, after that it will try to load the db service with idds1and use the datasource of that db service and feed into the current db service being configured. This allows multiple db service share the same datasource instance. Note app must make sure the db service been referenced has already configured and the db service must be an implementation ofSqlDbService. If a datasource is configured as shared datasource then it does not need to configure other datasource properties e.g. url, username etc. However thenaming.conventionstill needs to be configured to make the db service able to mapping between table/column and class/field. - otherwise if specified then it will try to load the
DataSourceProviderinstance by usingAct.getInstance(<value>) - if not specified then system will probe the class loader by try loading
com.zaxxer.hikari.HikariConfigorcom.alibaba.druid.pool.DruidDataSourceand load the hikari CP provider or druid provider respectively
Specify should datasource auto commit transaction
Default value: false
Specify the minimum connections should be created by data source
Default value: 2
Specify the maximum connections can be created by data source
Default value: 10
Specifies the default transaction isolation level, could be one of the following:
NONE- no transactionREAD_UNCOMMITTEDREAD_COMMITTEDREPEATABLE_READSERIALIZABLE
Default value: READ_COMMITTED
Specify the naming convention to map Entity class name to table name and the property name to column name
Supported values:
matching- map directly (could be case insensitive)underscore- convert camelcase to underscore notation
Default value: matching
The ddl configuration tells the framework whether or not to generate and run DDL scripts
Specify should framework to generate and run create table DDL
Default value: false unless h2 is used as database
Note about h2: if using h2 anbd the database file exists then ddl.create will always be treated as false unless ddl.drop is specified as true
Specify should framework to generate and run drop table DDL
Default value: false
String s = miscConf.get("idleTimeout");
if (null != s) {
int n = Integer.parseInt(s);
hc.setIdleTimeout(n);
} else {
hc.setIdleTimeout(conf.maxInactiveTimeSecs * 1000);
}s = miscConf.get("connectionInitSql");
if (null != s) {
hc.setConnectionInitSql(s);
}s = miscConf.get("maxLifetime");
if (null != s) {
long n = Long.parseLong(s);
hc.setMaxLifetime(n);
} else {
hc.setMaxLifetime(conf.maxAgeMinutes * 60 * 1000L);
}s = miscConf.get("poolName");
if (null != s) {
hc.setPoolName(s);
}DruidDataSource source = new DruidDataSource();
String s = miscConf.get("initialSize");
if (null != s) {
source.setInitialSize(Integer.parseInt(s));
} else {
source.setInitialSize(source.getMinIdle());
}s = miscConf.get("timeBetweenEvictionRunsMillis");
if (null != s) {
source.setTimeBetweenEvictionRunsMillis(Long.parseLong(s));
}s = miscConf.get("minEvictableIdleTimeMillis");
if (null != s) {
source.setMinEvictableIdleTimeMillis(Long.parseLong(s));
}s = miscConf.get("testWhileIdle");
if (null != s) {
source.setTestWhileIdle(Boolean.parseBoolean(s));
}s = miscConf.get("testOnBorrow");
if (null != s) {
source.setTestOnBorrow(Boolean.parseBoolean(s));
}s = miscConf.get("testOnReturn");
if (null != s) {
source.setTestOnReturn(Boolean.parseBoolean(s));
}s = miscConf.get("filters");
if (null != s) {
try {
source.setFilters(s);
} catch (SQLException e) {
throw E.unexpected(e);
}
}s = miscConf.get("poolPreparedStatements");
if (null != s) {
source.setPoolPreparedStatements(Boolean.parseBoolean(s));
}