1. 程式人生 > >常見的JedisConnectionException 異常

常見的JedisConnectionException 異常

最近在使用redis出現以下的異常:

1.redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection timed out

redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection timed out

2.redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
at redis.clients.util.Pool.getResource(Pool.java:22)

3.redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Socket is not connected

redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Socket is not connected

4.redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Socket closed

redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Socket closed

總結:
a.程式中一定存在沒有關閉的redis連線;
b.jedis驅動包版本過低,本專案報錯之前使用jedis-2.1.0.jar,現在專案使用jedis-2.7.3.jar,兩個版本在使用JedisPoolConfig 設定最大連線數的方法和等待時間方法不一樣;
c.jedis工具類:http://blog.csdn.net/lu_wei_wei/article/details/50906251