Package Com.guo.redis;import Redis.clients.jedis.Jedis; Public classRedis_1 { Public Static voidMain (string[] args) {//TODO auto-generated Method Stub//Connect to a remote Redis serviceJedis Jedis =NewJedis ("192.168.80.1",6379); //Permission Validation//Jedis.auth ("admin"); //See if the service is runningSystem. out. println (Jedis.ping ()); }}
The above code is the Java connection Redis but in the time of the connection always error, the method also found on the Internet, is basically comments off #127.0.0.1 firewall iptables, but the connection is not successful, finally found that these methods are actually correct only the configuration file is wrong, Because I registered Redis with the Linux system service, the Redis configuration file is also transferred from the Redis installation directory to the/etc/redis/6379.conf, if it is not useful to modify the configuration file under the Redis installation directory, And remember to put access rights off Proteced-mode No
Java Connectivity Redis Issues