Eclipse Write Java program implement connect Redis Database tutorial

Source: Internet
Author: User
Tags windows download redis server

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


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.