Thursday, 16 February 2017

[Redis] Connect Redis Server in Java

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package test.redis;

import redis.clients.jedis.Jedis;

/*
 * ************************************************************************************
 *
 * ConnectRedisServerTest.java
 * 
 * ************************************************************************************
 * 
 * @version 1.0.00 2017-02-10 dorbae Initialize
 * @since 2017-02-10
 * @author dorbae
 * 
 * ************************************************************************************
 */
public class ConnectRedisServerTest {

 public ConnectRedisServerTest() {
  // TODO Auto-generated constructor stub
 }

 public static void main(String[] args) {
  //Connecting to Redis server on localhost 
       Jedis jedis = new Jedis( "btcxen.esb.broker1", 6379); 
       System.out.println("Connection to server sucessfully"); 
       //check whether server is running or not 
       System.out.println("Server is running: "+jedis.ping());

 }

}




No comments:

Post a Comment