我已经编写了一个用于批量插入的java代码.我正在使用copy命令为不同的表导入和创建不同的连接对象,但在执行时,程序会抛出以下错误:
FATAL: connection limit exceeded for non-superusers
Run Code Online (Sandbox Code Playgroud)
小智 12
您已超过PostgreSQL服务器的连接限制.超级用户有一些保留的连接.
要增加连接限制,您必须更改postgresql.conf(默认值为100),它位于PostgreSQL数据目录中.
cat postgresql.conf | grep max_connection max_connections = 100
# (change requires restart)
# Note: Increasing max_connections costs ~400 bytes of shared memory per
# max_locks_per_transaction * (max_connections + max_prepared_transactions)
Run Code Online (Sandbox Code Playgroud)
增加限制并重新启动PostgreSQL实例.
警告:增加连接限制将影响内存.
尝试使用应用程序或数据库层中的连接池优化连接.在PostgreSQL上你可以使用Pgpool2.
Are you using a connection pool? Check if connections are closed properly in your code. This should be done in a try-finally block:
Connection connection = dataSource.getConnection();
try {
....
}
finally {
connection.close();
}
Run Code Online (Sandbox Code Playgroud)
If you really need a large amount of connections, set the max_connections-property in postres accordingly.
| 归档时间: |
|
| 查看次数: |
26316 次 |
| 最近记录: |