The first step is to configure the Redis database on the Windows download installation. I'm not going to outline it here. Download Jedis-2.4.2.jar, of course, it is best to download the latest version of the jar package.
This is in Baidu search under the out. After downloading, put in a folder below, you will need to.
The second step. Open Eclipse and create a new Java project. As shown in the following:
Step three: In Test this Java project, we create a new folder, named Lib, the Jedis-2.4.2.jar package we just downloaded is placed under our new Lib package, as shown in:
Fourth step, in Eclipse, select the jar package, under build path. And then we test this project inside we create a new class,class name for Testconnect.
Fifth step, in the class, we enter the following content:
Connecting to Redis server on localhost
Instantiate a client
Jedis Jedis = new Jedis ("localhost");
//=================================================
Check whether server is running or not
Ping it and see if it's through.
System.out.println ("Server is running:" + jedis.ping ());
Save a
Jedis.set ("leitest", "localhost Connection sucessfully");
Get a
The sixth step, run on the class just now, ctrl+f11 the shortcut key, as shown in:
The seventh step is to further verify whether we have saved the data on Redis, and we are able to remove it, we go to the Redis installer directory, for example, open the red box inside the Redis-cli.exe, open, we go to the second image below the interface.
Eighth Step: We enter get leitest this command on the interface of the Redis client. Leitest is a string type of key that we just deposited into the Redis database in Eclipse. If it proves that we did succeed, you should try it.
Eclipse Write Java program implement connect Redis Database tutorial