gpt4 book ai didi

hikaricp - 如何获取 HikariCP 的事件连接数

转载 作者:行者123 更新时间:2023-12-05 00:17:08 31 4
gpt4 key购买 nike

我试图记录当前事件连接的数量。我正在使用 com.zaxxer.hikari.HikariJNDIFactory作为我的数据源工厂。

final Context context = new InitialContext();
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setDataSource((DataSource) ((Context)context.lookup("java:comp/env")).lookup("jdbc/mydb"));
HikariPool hikariPool = new HikariPool(hikariConfig);
LOGGER.log(Level.INFO, "The count is ::" + hikariPool.getActiveConnections());

但它抛出以下异常:
java.lang.RuntimeException: java.lang.NullPointerException
at com.zaxxer.hikari.util.PoolUtilities.createInstance(PoolUtilities.java:105)
at com.zaxxer.hikari.metrics.MetricsFactory.createMetricsTracker(MetricsFactory.java:34)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:131)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:99)
at com.something.servlet.HikariConnectionCount.doGet(HikariConnectionCount.java:35)

哪里 HikariConnectionCount.java是我写的文件

最佳答案

关于hikaricp - 如何获取 HikariCP 的事件连接数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40784965/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com