java如何找到哪个应用程序保留Postgres连接?
有几个应用程序在Tomcat上运行。他们使用Postgres数据库,有时超过最大连接限制:
org.hibernate.exception.GenericJDBCException: Error calling Driver#connect at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
Caused by: org.postgresql.util.PSQLException: FATAL: remaining connection slots are reserved for non-replication superuser connections
at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java:684)
我曾试图提高限额,但问题仍然存在。如何找出哪个应用程序接管连接插槽
# 1 楼答案
将ApplicationName添加到连接字符串,如下所示:
然后,您将在中看到它:
当然,这只有在不同应用程序有单独的连接字符串时才有效
还要检查与JDBC的连接池上的一些info