private static ThreadLocal local = new ThreadLocal<>();
public static Connection getConnection() throws SQLException {
Connection conn = local.get();
if (conn == null) {
conn = DriverManager.getConnection(url, user, password);
local.set(conn);
}
return conn;
}
每次try结束后,总会抛出SQL异常,但如果把if删了的话,不会抛出,怎么解决啊?