應用未正確關閉連接,導致連接泄漏,達到 `max_connections` 限制 (默認 151)。
// Java try-with-resources
try (Connection conn = ds.getConnection();
PreparedStatement ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery()) {
// use rs
} // 自動關閉
SET GLOBAL max_connections = 500; -- 永久改 my.cnf