我真的被这个问题困扰了,所以我很高兴有人能帮助我!
当我在一分钟后登录时,系统注销,当我尝试再次登录时,我收到此错误: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:连接关闭后不允许任何操作。
我怎样才能防止这个连接关闭。最好的连接池是什么
注意:我仍然是一个学习者,正在做我的第一个 CRUD!数据库实用程序:
private static Connection connet;
public static Connection getConnection() {
if( connet != null )
return connet;
InputStream inputStream = DButil.class.getClassLoader().getResourceAsStream( "/db.properties" );
Properties properties = new Properties();
try {
properties.load( inputStream );
String url = properties.getProperty("url");
String driver = properties.getProperty("driver");
String userName = properties.getProperty("user");
String password = properties.getProperty("password");
Class.forName(driver);
connet = DriverManager.getConnection(url,userName,password);
} catch (IOException | ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
return connet;
}
// connection commit
public static void commit() { …Run Code Online (Sandbox Code Playgroud)