oracle链接问题

This commit is contained in:
fanghongchao
2018-12-24 14:32:20 +08:00
parent 7791bbf4d4
commit a4b28f718a
5 changed files with 24 additions and 2 deletions
@@ -49,7 +49,8 @@ public class PrimaryDataSourceConfig {
dataSource.setMaxWait(properties.getMaxWait()); dataSource.setMaxWait(properties.getMaxWait());
dataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis()); dataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis());
dataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis()); dataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis());
dataSource.setValidationQuery(properties.getValidationQuery());
return dataSource; return dataSource;
} }
} }
@@ -29,6 +29,8 @@ public class PrimaryDsProperties {
private boolean poolPreparedStatements; private boolean poolPreparedStatements;
private boolean testOnBorrow; private boolean testOnBorrow;
private String validationQuery;
public String getUrl() { public String getUrl() {
return url; return url;
@@ -133,4 +135,12 @@ public class PrimaryDsProperties {
public void setTestOnBorrow(boolean testOnBorrow) { public void setTestOnBorrow(boolean testOnBorrow) {
this.testOnBorrow = testOnBorrow; this.testOnBorrow = testOnBorrow;
} }
public String getValidationQuery() {
return validationQuery;
}
public void setValidationQuery(String validationQuery) {
this.validationQuery = validationQuery;
}
} }
@@ -46,6 +46,7 @@ public class SecondaryDataSourceConfig {
dataSource.setMaxWait(properties.getMaxWait()); dataSource.setMaxWait(properties.getMaxWait());
dataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis()); dataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis());
dataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis()); dataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis());
dataSource.setValidationQuery(properties.getValidationQuery());
return dataSource; return dataSource;
} }
@@ -30,6 +30,8 @@ public class SecondaryDsProperties {
private boolean testOnBorrow; private boolean testOnBorrow;
private String validationQuery;
public String getUrl() { public String getUrl() {
return url; return url;
} }
@@ -133,4 +135,12 @@ public class SecondaryDsProperties {
public void setTestOnBorrow(boolean testOnBorrow) { public void setTestOnBorrow(boolean testOnBorrow) {
this.testOnBorrow = testOnBorrow; this.testOnBorrow = testOnBorrow;
} }
public String getValidationQuery() {
return validationQuery;
}
public void setValidationQuery(String validationQuery) {
this.validationQuery = validationQuery;
}
} }
+1 -1
View File
@@ -26,7 +26,7 @@ spring:
driver: oracle.jdbc.driver.OracleDriver driver: oracle.jdbc.driver.OracleDriver
max-active: 30 max-active: 30
test-on-borrow: true test-on-borrow: true
validation-query: SELECT 1 validation-query: SELECT 1 FROM dual
initial-size: 10 initial-size: 10
min-idle: 1 min-idle: 1
max-wait: 60000 max-wait: 60000