【发布时间】:2022-07-20 00:37:34
【问题描述】:
我想对资源使用try,虽然我的程序在连接关闭后无法完成操作。
String conn = "jdbc:mysql://localhost:3306/test?&serverTimeZone=Europe/Moscow&useSSL=false&allowPublicKeyRetrieval=true";
try (Connection connection = DriverManager.getConnection( conn,"root","admin"))
{
return connection;
} catch (SQLException e) {
throw new RuntimeException(e);
}
【问题讨论】:
标签: java mysql connection