Merge branch 'stable-2.12' into stable-2.13
* stable-2.12: Fix DB connection pool verification Change-Id: Ia1ed831c7db397253d8b842e6fb69076898c5c4f
This commit is contained in:
@@ -21,6 +21,7 @@ import java.io.InputStream;
|
|||||||
|
|
||||||
public abstract class BaseDataSourceType implements DataSourceType {
|
public abstract class BaseDataSourceType implements DataSourceType {
|
||||||
|
|
||||||
|
private static final String DEFAULT_VALIDATION_QUERY = "select 1";
|
||||||
private final String driver;
|
private final String driver;
|
||||||
|
|
||||||
protected BaseDataSourceType(String driver) {
|
protected BaseDataSourceType(String driver) {
|
||||||
@@ -37,6 +38,11 @@ public abstract class BaseDataSourceType implements DataSourceType {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValidationQuery() {
|
||||||
|
return DEFAULT_VALIDATION_QUERY;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ScriptRunner getIndexScript() throws IOException {
|
public ScriptRunner getIndexScript() throws IOException {
|
||||||
return getScriptRunner("index_generic.sql");
|
return getScriptRunner("index_generic.sql");
|
||||||
|
|||||||
@@ -43,4 +43,9 @@ public class DB2 extends BaseDataSourceType {
|
|||||||
b.append(dbc.required("database"));
|
b.append(dbc.required("database"));
|
||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValidationQuery() {
|
||||||
|
return "SELECT 1 FROM SYSIBM.SYSDUMMY1";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,6 +137,8 @@ public class DataSourceProvider implements Provider<DataSource>,
|
|||||||
ds.setMaxWait(ConfigUtil.getTimeUnit(cfg, "database", null,
|
ds.setMaxWait(ConfigUtil.getTimeUnit(cfg, "database", null,
|
||||||
"poolmaxwait", MILLISECONDS.convert(30, SECONDS), MILLISECONDS));
|
"poolmaxwait", MILLISECONDS.convert(30, SECONDS), MILLISECONDS));
|
||||||
ds.setInitialSize(ds.getMinIdle());
|
ds.setInitialSize(ds.getMinIdle());
|
||||||
|
ds.setValidationQuery(dst.getValidationQuery());
|
||||||
|
ds.setValidationQueryTimeout(5);
|
||||||
exportPoolMetrics(ds);
|
exportPoolMetrics(ds);
|
||||||
return intercept(interceptor, ds);
|
return intercept(interceptor, ds);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ public interface DataSourceType {
|
|||||||
|
|
||||||
String getUrl();
|
String getUrl();
|
||||||
|
|
||||||
|
String getValidationQuery();
|
||||||
|
|
||||||
boolean usePool();
|
boolean usePool();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -41,4 +41,9 @@ class Derby extends BaseDataSourceType {
|
|||||||
}
|
}
|
||||||
return "jdbc:derby:" + site.resolve(database).toString() + ";create=true";
|
return "jdbc:derby:" + site.resolve(database).toString() + ";create=true";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValidationQuery() {
|
||||||
|
return "values 1";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,4 +43,9 @@ public class Oracle extends BaseDataSourceType {
|
|||||||
b.append(dbc.required("instance"));
|
b.append(dbc.required("instance"));
|
||||||
return b.toString();
|
return b.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValidationQuery() {
|
||||||
|
return "select 1 from dual";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user