diff --git a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/DataSourceValidator.java b/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/DataSourceValidator.java deleted file mode 100644 index ae1e4d1d7c0c52861397aa0c1d31af363f36df86..0000000000000000000000000000000000000000 --- a/apollo-common/src/main/java/com/ctrip/framework/apollo/common/utils/DataSourceValidator.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.ctrip.framework.apollo.common.utils; - -import org.apache.tomcat.jdbc.pool.Validator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.sql.Connection; - -/** - * @author Jason Song(song_s@ctrip.com) - */ -public class DataSourceValidator implements Validator { - private static final Logger LOGGER = LoggerFactory.getLogger(DataSourceValidator.class); - private static final int DEFAULT_VALIDATE_TIMEOUT_IN_SECONDS = 5; - - @Override - public boolean validate(Connection connection, int validateAction) { - boolean isValid = false; - try { - isValid = connection.isValid(DEFAULT_VALIDATE_TIMEOUT_IN_SECONDS); - } catch (Throwable ex) { - LOGGER.warn("Data source validation error", ex); - } - - return isValid; - } -} diff --git a/apollo-common/src/main/resources/application.properties b/apollo-common/src/main/resources/application.properties index cd6bc8f3d2eca3d012a6939062889783d8bdd4ce..d5fd3b29fdb187b01545ce7029e928945c3ad8f3 100644 --- a/apollo-common/src/main/resources/application.properties +++ b/apollo-common/src/main/resources/application.properties @@ -3,8 +3,7 @@ spring.http.converters.preferred-json-mapper=gson # DataSource spring.datasource.testWhileIdle=true spring.datasource.testOnBorrow=true -spring.datasource.validatorClassName=com.ctrip.framework.apollo.common.utils.DataSourceValidator -spring.datasource.validationInterval=5000 +spring.datasource.validationQuery=SELECT 1 spring.datasource.initSQL=set names utf8mb4 # Naming strategy