从剪贴板中拉出字符串时的键入问题

时间:2016-08-05 00:18:39

标签: java database redis

Toolkit toolkit = Toolkit.getDefaultToolkit();
    Clipboard clipboard = toolkit.getSystemClipboard();
    String result;
    try {
        result = (String) clipboard.getData(DataFlavor.stringFlavor);
        console.appendText("\nString being registerd to account: " + result);

        Jedis client = new Jedis("placeholder");
        client.rpush(userName, result);
        client.disconnect();
        client.close();

当我从按钮运行代码时,我收到一条错误消息,指出结果是错误的数据类型。是否与我从剪贴板中提取文本的方式有关,是否有其他方法可以执行此操作,因此不会抛出此错误?
堆栈:

Caused by: redis.clients.jedis.exceptions.JedisDataException: WRONGTYPE Operation against a key holding the wrong kind of value
at redis.clients.jedis.Protocol.processError(Protocol.java:117)
at redis.clients.jedis.Protocol.process(Protocol.java:151)
at redis.clients.jedis.Protocol.read(Protocol.java:205)
at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:297)
at redis.clients.jedis.Connection.getIntegerReply(Connection.java:222)
at redis.clients.jedis.Jedis.rpush(Jedis.java:813)
at Commands.NEW.excecute(NEW.java:25)
at Controllers.mainController.parseCommand(mainController.java:100)
at Controllers.mainController.submitHandler(mainController.java:57)
... 58 more

1 个答案:

答案 0 :(得分:-1)

我试图在没有选择合适的数据库的情况下推动它。