连接超时,怎么解决
redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out at redis.clients.jedis.Connection.connect(Connection.java:207) at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:93) at redis.clients.jedis.Connection.sendCommand(Connection.java:126) at redis.clients.jedis.Connection.sendCommand(Connection.java:117) at redis.clients.jedis.BinaryClient.auth(BinaryClient.java:564) at redis.clients.jedis.BinaryJedis.auth(BinaryJedis.java:2138) at com.imooc.jedis.JedisTestor.main(JedisTestor.java:9) Caused by: java.net.SocketTimeoutException: connect timed out at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at redis.clients.jedis.Connection.connect(Connection.java:184) ... 6 more Process finished with exit code 0
18
收起
正在回答 回答被采纳积分+1
2回答
csm032
2020-06-01 16:44:54
package com.imooc.jedis; import redis.clients.jedis.Jedis; public class JedisTestor { public static void main(String[] args) { Jedis jedis=new Jedis("192.168.124.128",6380); try { jedis.auth("12345"); jedis.select(2); System.out.println("Redis连接成功"); }catch (Exception e){ e.printStackTrace(); }finally { jedis.close(); } } }
3. Java 数据库开发与实战应用
- 参与学习 人
- 提交作业 357 份
- 解答问题 8016 个
本阶段将带你学习MySQL数据库,JDBC接口,MyBatis框架等,带你掌握的数据的存放和管理。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星