java.sql.SQLRecoverableException: No more data to read from socket when using a connection pool?

最后都变了- 提交于 2019-12-06 13:39:22

问题


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

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 ?


回答1:


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

The Reason:

  • 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.

The Solution:

  • 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)

Reference Link



来源:https://stackoverflow.com/questions/27898780/java-sql-sqlrecoverableexception-no-more-data-to-read-from-socket-when-using-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!