使用JDBC连接到mysql数据库时出现此错误.
Database.getConnection() Error -->The server time zone value 'EEST' is
unrecognized or represents more than one time zone. You must configure
either the server or JDBC driver (via the serverTimezone configuration
property) to use a more specifc time zone value if you want to utilize
time zone support.
Run Code Online (Sandbox Code Playgroud)
那是我的连接代码.
public static Connection getConnection(){
try {
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/management", "root", "root");
return con;
} catch (ClassNotFoundException | SQLException e) {
// TODO Auto-generated catch block
System.out.println("Database.getConnection() Error -->" …Run Code Online (Sandbox Code Playgroud) 我有一个这样的加载缓存:
MyCacheLoader loader=new MyCacheLoader();
MyRemovalListener listener=new MyRemovalListener();
LoadingCache<String, String> myCache = CacheBuilder.newBuilder()
.concurrencyLevel(10)
.weakKeys()
.maximumSize(2)
.expireAfterWrite(120, TimeUnit.SECONDS)
.removalListener(listener)
.build(loader);
Run Code Online (Sandbox Code Playgroud)
但是当我做这样的事情来测试时:
System.out.println(myCache.get("100"));
System.out.println(myCache.get("103"));
System.out.println(myCache.get("110"));
System.out.println(myCache).get("111"));
Thread.sleep(230000);
System.out.println(myCache.size());
Run Code Online (Sandbox Code Playgroud)
我仍然得到 2 而不是零。为什么 ?超过 120 秒后,如果我没有错的话,我的大小应该为零吗?
我的缓存加载器
public class MyCacheLoader extends CacheLoader<String,String> {
@Override
public String load(String key) throws Exception {
return key;
}
}
Run Code Online (Sandbox Code Playgroud)
我的移除监听器
public class MyRemovalListener implements RemovalListener<String,String> {
Logger logger = LoggerFactory.getLogger(MyRemovalListener.class);
@Override
public void onRemoval(RemovalNotification<String, String> removalNotification) {
logger.info("Message with message Id ("+
removalNotification.getKey()+ ") is removed.");
System.out.println("Message with …Run Code Online (Sandbox Code Playgroud)