精华内容
下载资源
问答
  • Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR wrong number of arguments for 'hset' command at redis.clients.jedis.Protocol.processError(Protocol.java:66) at redis.clien...

    报错:

    Caused by: redis.clients.jedis.exceptions.JedisDataException: ERR wrong number of arguments for 'hset' command
        at redis.clients.jedis.Protocol.processError(Protocol.java:66)
        at redis.clients.jedis.Protocol.process(Protocol.java:73)
        at redis.clients.jedis.Protocol.read(Protocol.java:138)
        at redis.clients.jedis.Connection.getIntegerReply(Connection.java:191)
        at redis.clients.jedis.Jedis.zrem(Jedis.java:1440)
        at com.gamejelly.gong.global.dbs.service.GlobalJedisService$26.doInJedis(GlobalJedisService.java:750)
        at com.hadoit.game.common.framework.nosql.redis.JedisTemplate.execute(JedisTemplate.java:79)
        at com.gamejelly.gong.global.dbs.service.GlobalJedisService.delRedisKeys(GlobalJedisService.java:746)
        at com.gamejelly.gong.global.dbs.proxy.GlobalCommandProxy.delRedisKeys(GlobalCommandProxy.java:642)
        at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at com.hadoit.game.engine.core.utils.method.MethodInvoationWrap.invoke(MethodInvoationWrap.java:63)
    

    原因:

    jedis.hset(key, map) 数组参数delkeys长度为0,即抛出该异常
    

    扩展:
    网上查到jedis还有很多方法都会抛出该异常,原因与此一致。jedis 不定长度参数方法都有这个问题,大家要注意一下~

    展开全文
  • Exception in thread "Thread-3" redis.clients.jedis.exceptions.JedisDataException: ERR unknown command 'SENTINEL' at redis.clients.jedis.Protocol.processError(Protocol.java:118) at redis.clients

    这里写图片描述

    Exception in thread "Thread-3" redis.clients.jedis.exceptions.JedisDataException: ERR unknown command 'SENTINEL'
        at redis.clients.jedis.Protocol.processError(Protocol.java:118)
        at redis.clients.jedis.Protocol.process(Protocol.java:152)
        at redis.clients.jedis.Protocol.read(Protocol.java:206)
        at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:266)
        at redis.clients.jedis.Connection.getRawObjectMultiBulkReply(Connection.java:232)
        at redis.clients.jedis.Connection.getObjectMultiBulkReply(Connection.java:237)
        at com.cares.sh.redis.Jredis.sentinelMasters(Jredis.java:72)
        at com.cares.sh.redis.RedisPool.run(RedisPool.java:37)

    解决办法:可以重新部署 换个端口试一下!

    展开全文
  • 使用Jedis连接虚拟机上的Redis数据库时,出现错误,记录下解决方法错误redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refus: connect修改配置文件redis.conf,...

    使用Jedis连接虚拟机上的Redis数据库时,出现错误,记录下解决方法

    错误

    redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refus: connect

    修改配置文件redis.conf,将bind注释掉,允许外面的机器连接

    这里写图片描述

    在修改后出现新的问题:

    redis.clients.jedis.exceptions.JedisDataException: 
    DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions:
     1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent.
     2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server.  
     3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 
     4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
        at redis.clients.jedis.Protocol.processError(Protocol.java:117)
        at redis.clients.jedis.Protocol.process(Protocol.java:142)
        at redis.clients.jedis.Protocol.read(Protocol.java:196)
        at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:288)
        at redis.clients.jedis.Connection.getBinaryBulkReply(Connection.java:207)
        at redis.clients.jedis.Connection.getBulkReply(Connection.java:196)
        at redis.clients.jedis.Jedis.hget(Jedis.java:606)
        at com.wds.jdemo.JedisTest.test(JedisTest.java:12)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
        at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

    这个问题是由于Redis是在守护状态下运行的,如果不是本地连接,就会报错,解决方法在问题描述中已经给出: 
    1)在Redis运行时,本地连接使用命令:CONFIG SET protected-mode no,但是要确保Redis不在公网上运行,使用CONFIG REWRITE是改变永久生效

    2)修改配置文件redis.conf,将protected mode 的值改为no,并重新启动redis服务

    3) 重新启动服务,在启动命令后加上protected-mode no参数

    4)绑定ip地址或设置一个密码

    本次采用了第二种解决方案

    连接Redis

    导包 
    这里写图片描述

    代码

    import org.junit.Test;
    
    import redis.clients.jedis.Jedis;
    import redis.clients.jedis.JedisPool;
    import redis.clients.jedis.JedisPoolConfig;
    
    public class JedisTest {
    
        /**
         * 单实例连接数据库 
         */
        @Test
        public void test(){
            Jedis jedis = new Jedis("192.168.47.130",6379);
    //      System.out.println(jedis.hget("hash", "uname"));
            jedis.hset("hash", "pwd", "123");
        }
    
        /**
         * 使用连接池
         */
        @Test
        public void test1(){
            //1.设置连接池的配置对象
            JedisPoolConfig config = new JedisPoolConfig();
            //设置池中最大连接数
            config.setMaxTotal(50);
            //设置空闲时池中保有的最大连接数
            config.setMaxIdle(10);
            //2.设置连接池对象
            JedisPool pool = new JedisPool(config,"192.168.47.130",6379);
            //3.从池中获取连接对象
            Jedis jedis = pool.getResource();
            System.out.println(jedis.hget("hash", "uname"));
            //4.连接归还池中
            jedis.close();
    
        }
    }

    转载地址:https://blog.csdn.net/sinat_36553913/article/details/78697967

    展开全文
  • 第一次安装在本地redis服务,试试跑项目,结果却出现nested exception is redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required错误,真是让人头疼 先检查一下配置文...

    第一次安装在本地redis服务,试试跑项目,结果却出现nested exception is redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required错误,真是让人头疼

    先检查一下配置文件

    这里是没有问题的,然后跑起来还是会出现同样的错误(检查发现自己在安装Redis的时候设置了redis的启用密码,找到redis的安装目录找到redis.windows-service.conf和redis.windows.conf两个配置文件,找到requirepass属性将其注释掉,如果在安装redis时没有设置密码可跳过此步),找到本地安装Tomcat的conf目录下面的context.xml文件添加以下配置

    转载于:https://my.oschina.net/Tarry/blog/3094402

    展开全文
  • 分片连接池实现方式:《Springmvc+redis jedis.jar连接方式,ShardedJedisPool分片连接池》需要的jar包:redis-2.6.1.jarredis.properties配置:redis.maxIdle=300 redis.maxTotal=600 redis.maxWaitMillis=1000 ...
  • 在使用Jedis连接虚拟机上的Redis数据库时,出现错误,记录下解决方法错误
  • 业务场景 ...推测抛出异常的原因 第一次访问接口时通过void setEntryInHash(String key,String field,String vlaue)方法在redis中存放用户访问当前接口的次数为1,此时不会抛出异常,通过redis命令查看存放的数据为 ...
  • redis.clients.jedis.exceptions.JedisDataException: WRONGTYPE Operation against a key holding the wrong kind of value 原因: 使用了不属于某个key存储类型的方法。 某key中存储的为set 你却用...
  • jedis-2.9.0.jar

    2017-09-25 14:08:06
    long saved = jedis.hset(key, field, value); System.out.println("hashBytesSaved:"+saved); } static void hashBytesGet(Jedis jedis) { byte[] key = "Tables".getBytes(); byte[] field = "9"....
  • 博文标题:_00021 妳那伊抹微笑_谁的异常最诡异第二期之 Jedis pool.returnResource(jedis) 个性签名:世界上最遥远的距离不是天涯,也不是海角,而是我站在妳的面前。妳却感觉不到我的存在 技术方向:Flume+Kafka...
  • 项目中用的是RedisTemplate操作redis,但是某些api只有原生jedis里才有,比如jedis.hset 我们可以通过RedisTemplate获取原生Jedis,来满足我们的需求。 代码如下 RedisConnection conn= null; try { conn = ...
  • import java.util.Map; import redis.clients.jedis.Jedis; public class RedisTest { ... public static void main(String[] args) { ... jedis.hset("student.scofield", "English", "45"); ...
  • 6.Jedis例子

    2019-11-20 21:25:51
    JedisUtil.java package com.gf.redisservice.service... import org.springframework.stereotype.Service; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedi...
  • 2.5 Jedis的基本操作之HashHash增加新值会替代旧值 jedis.hset("car", "name", "bmw"); jedis.hset("car", "price", "1000000");对应redis-cli中的命令为redis> HSET car name bmw redis> HSET car price 1000000...
  • 操作示例: public void operateHash() { Jedis jedis = new Jedis("127.0.0.1", 6379); //测试是否链接成功,返回pong则代表链接成功 ... System.out.println("jedis.hset(\"user:01\", \"name\", \"jiejie\"):
  • 我出现此异常是因为在向散列hash中添加map时使用hset命令。 jedis.hset("hash",map); //即使map不为空,这样使用也会出错 正确写法: jedis.hmset("hash",map);
  • Jedis使用

    2020-09-14 07:41:57
    目录一、简单连接二、整合spring ...import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisCluster; import redis.clients.jedis.JedisPool; import java.util.HashSet; import java
  • Jedis学习

    2021-01-11 18:36:24
    获取连接 Jedis jedis = new Jedis("localhost",6379); //空参默认 localhost 6379 操作 jedis.set("username","zhangsan"); 关闭连接 jedis.close(); 各数据类型操作: String jedis.set("key","value") ...
  • jedis

    2019-12-01 20:08:09
    jedis操作 1.获取连接 Jedis jedis = new Jedis();//如果使用空参构造,默认值为"locahost",“6379” 2.操作 存储 jedis.set(“username”,“zhangsan”) 获取 jedis.get() 3.关闭连接 jedis.close() Jdeis操作各种...
  • Jedis

    2019-09-19 19:12:19
    Java客户端 Jedis * Jedis: 一款java操作redis数据库的工具. * 使用步骤: 1. 下载jedis的jar包 2. 使用 //1. 获取连接 Jedis jedis = new Jedis("localhost",6379); //2. 操作 jedis.set("username",...
  •  atredis.clients.jedis.JedisPool.(JedisPool.java:24)  atredis.clients.jedis.JedisPool.(JedisPool.java:29)  atcn.adsit.iva.preroll.dp.synch.analysis.redis.util.ConsistentHashRedisUtils....
  • jedis工具类

    2018-05-15 13:46:32
    package ... import org.slf4j.Logger; import org.slf4j.LoggerFactory; import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig;...
  • jedisAPI

    2019-09-03 11:41:06
    1.jedis操作key值 select jedis.select(1) 选择0-15任意一个库 flushDB jedis.flushDB() 清除数据库数据 exists jedis....
  • Jedis使用+jedis再封装

    千次阅读 2016-06-04 12:16:27
    一 、Redis初始化(RedisStart.class) ...import redis.clients.jedis.Jedis; import redis.clients.jedis.JedisPool; import redis.clients.jedis.JedisPoolConfig; /**  * Created b

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 10,175
精华内容 4,070
关键字:

jedis.hset