首页 新闻 会员 周边 捐助

400个线程同时查询数据,抛出一个异常

0
[已解决问题] 解决于 2017-12-04 09:46
十二月 03, 2017 4:28:33 下午 org.postgresql.Driver connect
严重: Connection error: 
org.postgresql.util.PSQLException: 尝试连线已失败。
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:275)
    at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
    at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:194)
    at org.postgresql.Driver.makeConnection(Driver.java:450)
    at org.postgresql.Driver.connect(Driver.java:252)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at com.mis.util.Jdbc.open(Jdbc.java:39)
    at com.mis.util.Jdbc.dql(Jdbc.java:56)
    at com.mis.dao.UserDao.getUserList(UserDao.java:14)
    at com.mis.service.UserService.getUserList(UserService.java:18)
    at com.mis.servlet.UserServlet.doGet(UserServlet.java:30)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.SocketException: Permission denied: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:83)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at org.postgresql.core.PGStream.<init>(PGStream.java:68)
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:144)
    ... 33 more
renguanyu的主页 renguanyu | 小虾三级 | 园豆:841
提问于:2017-12-03 16:30
< >
分享
最佳答案
0

在com.mis.dao.UserDao.getUserList(UserDao.java:14)

在com.mis.service.UserService.getUserList(UserService.java:18)

很多时候 java.net.SocketException: Connection Reset
是应用层协议的一个错误,己方尝试读取流中数据,但对方已经关闭连接,可能正常关闭也可能异常关闭,原因多种多样,可能数据库连接根本就没建立起来,具体配置不清楚

你的问题应该是由于权限不足造成的,你可以这么试试看:

1. 首先你确定你的数据库是开着的,保证可以连接上。
2. 确定你是jar和url连接数据库没问题。
3. 程序里面的问题不大,还是在你连接数据库这里。
最后,你可以写个简单的jdbc连接试试看。

奖励园豆:5
回首笑人间 | 菜鸟二级 |园豆:217 | 2017-12-03 22:06
其他回答(1)
0

http://blog.csdn.net/jiangshubian/article/details/76549073

Daniel Cai | 园豆:10424 (专家六级) | 2017-12-03 22:17
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册