The driver was unable to create a connection due to an inability to establish the client portion of a socket.
This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable.
For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required.
数据库没问题,每次查询完执行:
if(rs!=null){
try {
rs.close();
} catch (Exception e) {
// TODO: handle exception
}
}
//关闭资源[先开后闭];
if(ps!=null){
try {
ps.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ps=null;//使用垃圾回收.
}
if(ct!=null){
try {
ct.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ct=null;
}
在一个方法里有个循环要反复去查询数据库,每次都是调用工具类去查询,也就是每次都执行了上面的关闭。可当查询到4000次左右时就抛出了上面的异常。请帮忙看看,万分感谢!
这个问题很简单,你加个连接缓冲池就OK了。因为你写了连接关闭,但是数据库连接没有立马关闭,需要等待一小段时间才会关闭。
我猜测有可能是你没有清空数据库连接池,到第4000次的时候,连接池的链接线程已经满了,所以才连不上。
你是不是每次循环都commit一次
应该是总体做完操作后再commit会好一些
最好把代码贴出来看下
我也遇到这个问题,楼主解决了吗
把代码贴出来看下啊
注意下Connection
一个connection可以打开多个Statement,但是一个Statment只能打开一个Resultset
每次打开的Resultset使用完后记得关闭即可,如果直接关闭Statment,会自动关闭Resultset,关闭以后不用再自动 rs = null;这是完全没有必要的!
整体来说,记得关闭Resultset,不要打开太多connection
For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required.
这很明显是 linux 服务器的 ulimit 限制住了 ulimit 你把这个参数 加大了 试试 在 /etc/profile 里
呵呵,耐心读一下所有提示信息,你就会有问题的一个大置方向
[quote]The driver was unable to create a connection due to an inability to establish the client portion of a socket.
This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable. [/quote]这个很明显就是说,你连接数量已经超过了。。。。如果你想再连接,你可以通过改配置文件加大数量。
楼主,你是否有关闭 Connection?是否有关闭Statment?
建立一个连接池就可以