【转】Jedis常见异常汇总

本文转载了Jedis常见异常汇总。Jedis使用简单,但参数设置不合理或功能使用不当会产生问题。文中列举了如JedisConnectionException、JedisDataException等多种异常情况,还给出了相关异常的详细说明链接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

【转载】Jedis常见异常汇总,总结的相当详细!!
Jedis虽然使用起来比较简单,但是如果不能根据使用场景设置合理的参数(例如连接池参数),不合理的使用一些功能(例如Lua和事务)也会产生很多问题,本文对这些问题逐个说明:

详细目录:
一、redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
二、redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream
三、redis.clients.jedis.exceptions.JedisDataException: ERR illegal address
四、redis.clients.jedis.exceptions.JedisDataException: ERR max number of clients reached
五、redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: Read timed out
六、redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required
七、redis.clients.jedis.exceptions.JedisDataException: EXECABORT Transaction discarded because of previous errors
八、java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.List
九、redis.clients.jedis.exceptions.JedisDataException: WRONGTYPE Operation against a key holding the wrong kind of value
十、redis.clients.jedis.exceptions.JedisDataException: OOM command not allowed when used memory > ‘maxmemory’
十一、redis.clients.jedis.exceptions.JedisDataException: LOADING Redis is loading the dataset in memory
十二、redis.clients.jedis.exceptions.JedisDataException: BUSY Redis is busy running a script. You can only call SCRIPT KILL or SHUTDOWN NOSAVE.
十三、redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out
十四、UNKILLABLE Sorry the script already executed write commands against the dataset. You can either wait the script termination or kill the server in a hard way using the SHUTDOWN NOSAVE command.
十五、java.lang.NoClassDefFoundError
十六、redis.clients.jedis.exceptions.JedisDataException: ERR unknown command
十七、redis.clients.jedis.exceptions.JedisDataException: Please close pipeline or multi block before calling this method.
十八、redis.clients.jedis.exceptions.JedisDataException: ERR command role not support for normal user.

详见:https://yq.aliyun.com/articles/236384?spm=a2c4e.11153940.blogcont236383.20.d17a1c96Lm3AHM#cc8

redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused (Connection refused) 表示在与Redis服务器建立连接时发生了连接被拒绝的异常。这可能是由于以下几种原因引起的。 1. Redis服务器未启动或未正确配置。请确保Redis服务器正在运行,并且已经正确配置了端口和IP地址。 2. 网络连接问题。请检查网络连接是否正常,确保能够与Redis服务器建立连接。 3. 鉴权密码错误。如果Redis服务器设置了密码鉴权,客户端在连接时需要提供正确的密码。如果客户端没有提供密码或提供了错误的密码,会导致连接被拒绝。 解决这个问题的方法有以下几种: 1. 检查Redis服务器是否正常运行,并确保配置正确。 2. 检查网络连接是否正常,尝试重新连接Redis服务器。 3. 如果Redis服务器设置了密码鉴权,确保客户端在连接时提供正确的密码。 请根据具体情况采取相应的解决方法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [详解Redis开启远程登录连接](https://download.youkuaiyun.com/download/weixin_38740201/14836767)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatgptT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [Redis常见异常汇总](https://blog.youkuaiyun.com/Huangjiazhen711/article/details/127424204)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatgptT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值