【问题标题】:How to find the active number of open database connections in H2/MySQL如何在 H2/MySQL 中找到打开的数据库连接的活动数
【发布时间】:2011-09-02 12:29:51
【问题描述】:

如何在 H2/MySQL 中找到打开的数据库连接的活动数。我们需要这些信息来确定是否存在任何连接泄漏。

【问题讨论】:

    标签: mysql h2


    【解决方案1】:

    对于 H2,使用:

    select * from information_schema.sessions;
    

    对于 MySQL,使用:

    show full processlist;
    

    select * from information_schema.processlist;
    

    如果您只对会话数感兴趣,请使用 select count(*) 而不是 select *

    【讨论】:

    • 从 information_schema.sessions 中选择 *; ID USER_NAME SESSION_START STATEMENT STATEMENT_START 2 USER1 2011-05-27 09:09:44.98 null 2011-05-27 09:09:48.139 3 USER1 2011-05-27 10:56:32.769 select * from information_schema.sessions 2011-05- 27 10:56:34.316
    • 我在运行上面的SQL语句时得到了上面的信息,但是没有得到关于连接数的信息。我错过了什么
    • select count(*) from information_schema.sessions; select count(*) from information_schema.processlist;
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-08
    • 1970-01-01
    • 2012-08-06
    • 2020-08-12
    • 1970-01-01
    相关资源
    最近更新 更多