[mysql] Set server time zone information for connection pool factory (#566)

pull/568/head
Leonard Xu 3 years ago committed by GitHub
parent 7f32e4d7c1
commit aa3e282cfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,6 +28,7 @@ public class PooledDataSourceFactory {
public static final String JDBC_URL_PATTERN =
"jdbc:mysql://%s:%s/?useInformationSchema=true&nullCatalogMeansCurrent=false&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&zeroDateTimeBehavior=CONVERT_TO_NULL";
public static final String CONNECTION_POOL_PREFIX = "connection-pool-";
public static final String SERVER_TIMEZONE_KEY = "serverTimezone";
private PooledDataSourceFactory() {}
@ -43,6 +44,7 @@ public class PooledDataSourceFactory {
config.setPassword(sourceConfig.getPassword());
config.setMaximumPoolSize(sourceConfig.getConnectionPoolSize());
config.setConnectionTimeout(sourceConfig.getConnectTimeout().toMillis());
config.addDataSourceProperty(SERVER_TIMEZONE_KEY, sourceConfig.getServerTimeZone());
// optional optimization configurations for pooled DataSource
config.addDataSourceProperty("cachePrepStmts", "true");

Loading…
Cancel
Save