I have created a db connection class.
import java.sql.*;
public class DBClass {
private static final String driver = "com.mysql.cj.jdbc.Driver";
private static final String url = "jdbc:mysql://localhost:3306/guestbook";
private static final String options = "?autoReconnect=true&validationQuery=select 1&useSSL=false&serverTimezone=UTC";
private static final String user = "root";
private static final String pass = "*****";
private static Connection conn = null;
static {
try {
Class.forName(driver + options);
}catch(Exception ex) {
ex.printStackTrace();
}
}
public static Connection getConnection() throws Exception{
if(conn == null) {
conn = DriverManager.getConnection(url, user, pass);
}
return conn;
}
}
I imported it as **<%@ page import="DbClass"%>** in the writing jsp page and did Connection conn=DBClass.getConnection() .
The article is well registered.
But when I go to the list page, No operations allowed after connection closed.
will be please tell me the cause