java.sql.SQLRecoverableException:使用连接池时,没有更多数据要从套接字读取? [英] java.sql.SQLRecoverableException: No more data to read from socket when using a connection pool?

查看:4967
本文介绍了java.sql.SQLRecoverableException:使用连接池时,没有更多数据要从套接字读取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用连接池连接到数据库时,我得到了这个异常。

When I connect to a database using a connection pool I get this exception.

然后我尝试使用基本的Class.forName()连接到数据库;和DriverManager方法我能够这样做..为什么会发生这种情况?

So then I tried connecting to the database using the basic Class.forName(); and DriverManager method I was able to do so.. why is this happening ?

推荐答案

无论连接池在哪里都可能出现此问题参与其中。原因如下。

This problem may arise wherever a connection pool is involved. The reason for this is as follows.

原因:


  • 在您的应用程序中说您已配置连接池。你要求一个5连接对象。

  • 您的连接池通常由像Tomcat,Spring或CQ5这样的容器处理(在我的情况下)

  • 现在您将应用程序保持空闲状态一段时间,但容器和连接池仍处于活动状态

  • 现在是魔术,数据库服务器按计划重新启动。

  • 这使得应用程序服务器连接中的活动/活动连接对象池已破获

  • 所以你来到下一刻,突然间你得到了这些错误在一段时间之前工作正常。

  • Say in your application you have configured a connection pool. And you ask for a 5 connection objects.
  • Your connection pool is usually handled by a Container like Tomcat, Spring, or CQ5(in my case)
  • Now you leave your application idle for some time, but the container and the connection pool is still active
  • And now the magic trick, the Database server restarts as per schedule.
  • This makes the alive/active connection objects inside your application servers's connection Pool BROKEN
  • So you come in the next moment and suddenly you get these errors when it was working fine some time ago.

解决方案:


  • 您可以重置连接池 - 这是最佳选择。这将删除驻留在池中的当前已断开的连接,并强制创建一个新的连接池,其中包含新的连接对象。

  • You can reset the connection pool- This is the best option. This would delete the current broken Connections residing in the pool and forcefully create a new Connection Pool with new connection objects inside them.

您可以重新启动应用程序服务器。不推荐。(你不能继续在生产中重启应用服务器)

You can restart the application server. Not recommended.(You can't keep restarting application servers in Production)

参考链接

这篇关于java.sql.SQLRecoverableException:使用连接池时,没有更多数据要从套接字读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆