java 使用reids做缓存出现redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

1、首先链接服务器 使用redis-cli

2、info

3、查看# Clients

connected_clients:23

client_longest_output_list:0

client_biggest_input_buf:0

blocked_clients:0


总结:创建连接池,一定要释放连接池。

/**

* 获取Jedis实例

    * @return

    */

  public synchronized static JedisgetJedis() {

try {

if (jedisPool !=null) {

Jedis resource =null;

              try {

resource =jedisPool.getResource();

                  return resource;

              }finally {

jedisPool.returnResource(resource);

              }

}else {

return null;

          }

}catch (Exception e) {

e.printStackTrace();

return null;

      }

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。