 | // MySQL 500人效能優化參數
// MySQL 500人效能優化參數 (確保與 properties 檔案一致)
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "500"); // 增加快取大小
config.addDataSourceProperty("prepStmtCacheSqlLimit", "4096"); // 增加SQL限制
config.addDataSourceProperty("useServerPrepStmts", "true");
config.addDataSourceProperty("elideSetAutoCommits", "true");
config.addDataSourceProperty("maintainTimeStats", "false");
_source = new HikariDataSource(config);
_log.info("生產級 HikariCP 配置載入成功");
return true;
} catch (Exception e) {
_log.log(Level.WARNING, "載入生產級配置失敗,將使用後備配置: " + e.getMessage());
_log.log(Level.INFO, "詳細錯誤資訊: ", e);
return false;
| |