The new version 5.1.33 of MySQL JDBC driver work with UTC time zone. Developers need to specify serverTimezone value explicitly in the connection string.
So, In MySQL driver property been you should to set "datasourceURL" like bellow:
jdbc:mysql://localhost/db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
If you are using Spring boot 2.x then you my configure your Databse been as like bellow:
@Configuration
public class DatabaseConfig {
@Bean
public DataSource getDataSource() {
String connecting = "jdbc:mysql://localhost/database_name?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC";
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");");
dataSource.setUrl(connecting);
dataSource.setUsername(""); // username
dataSource.setPassword("");
// password
return dataSource;
}
}
Hopefully solve your problem.
No comments:
Post a Comment