问题描述
通过Java应用程序连接到数据库时,我们面临异常.堆栈跟踪如下
We are facing an exception while connecting to database through our java application. The stack trace is as follows
com.edb.util.PSQLException: The connection attempt failed.
at com.edb.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:189)
at com.edb.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
at com.edb.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:161)
at com.edb.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at com.edb.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
at com.edb.Driver.makeConnection(Driver.java:391)
at com.edb.Driver.connect(Driver.java:266)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
... 12 more
Caused by: java.net.SocketException: No buffer space available (maximum connections reached?): connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at com.edb.core.PGStream.<init>(PGStream.java:70)
at com.edb.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:115)
... 20 more
发生错误时,我们无法连接到Internet和DB,必须重新启动系统.但是在3天后以相同的代码再次发生错误,即在连接到DB时.我们使用netstat检查了TCP连接.但是TCP连接不多,即未达到最大限制.
When the error occured we were not able to connect to internet and DB and had to reboot the system. But the error occured again after 3 days at same code i.e while connecting to DB. We checked TCP connections using netstat. But there were not many TCP connections i.e it has not reached the max limit.
我们的应用程序具有多个运行时间较长的Java进程,这些进程会池化数据库连接(不超过60个),并使其保持活动状态以引发下一个查询(因为它必须每2秒轮询一次数据库).我们应用程序中的某些查询正在联接大表(1000万条记录)以获取相关数据.
Our application has multiple long running Java processes that pools the DB connections (not more than 60) and keeps it alive for firing the next query (as it has to poll the DB every 2 seconds). Some of the queries in our application are joining large tables (10 million records) to get the related data.
我们正在使用以下系统和应用程序
We are using following System and applications
- Windows 2003服务器SP2
- Java 1.6
- Postgres Plus Advanced服务器8.4数据库
-
edb-jdbc14.jar
驱动程序,用于来自Java的连接数据库
- Windows 2003 server SP2
- Java 1.6
- Postgres Plus Advanced server 8.4 Database
edb-jdbc14.jar
driver for connection DB from Java
我们使用了Postgres DB的默认配置,只是将连接数从100增加到120.
We have used the default configuration of Postgres DB except increasing the connection to 120 from 100.
有人用postgres edb驱动程序遇到了相同的错误吗?
Has anybody encountred the same error with postgres edb driver?
有人可以帮助我们找到解决方案吗?
Can anybody help us finding the solution?
推荐答案
这看起来像一个客户端问题-它甚至连服务器都无法连接.当PostgreSQL或Advanced Server的可用服务器连接用尽时,它不是您从PostgreSQL或Advanced Server中收到的错误.
This looks like a client side problem - it never manages to even connect to the server. It is not the error you get from the PostgreSQL or Advanced Server when it runs out of available server connections.
问题可能出在客户机程序/JVM的资源中,还是在EDB JDBC驱动程序中的某处.如果您在JVM中找不到任何不正确的信息,并且由于您使用的是PostgreSQL Plus Advanced Server,我建议您使用EnterpriseDB支持来获得有关其JDBC驱动程序的帮助. (与PostgreSQL不同)
The problem is either in the resources for your client program/JVM, or somewhere in the EDB JDBC driver. If you can't find something incorrect in your JVM, and since you're on PostgreSQL Plus Advanced Server, I would suggest you use EnterpriseDB support for help with their JDBC driver. (Which is different from the PostgreSQL one)
这篇关于没有可用的缓冲区空间(已达到最大连接?)表格Postgres EDB驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!