(2) using Redis in Java projects

Source: Internet
Author: User
Tags redis
Java using Redis installation

Before we start using Redis in Java, we need to make sure that the Redis service and the Java Redis Drive are installed and that Java is available on your machine. Java installation configuration can refer to the Java Development environment configuration next let's install the Java Redis driver:

Use Java operation Redis need jedis-2.1.0.jar, download address: Http://files.cnblogs.com/liuling/jedis-2.1.0.jar.zip

If you need to use Redis connection pool, also need Commons-pool-1.5.4.jar, download address: Http://files.cnblogs.com/liuling/commons-pool-1.5.4.jar.zip Connecting to the Redis service

Import Redis.clients.jedis.Jedis;
public class Redisjava {public
   static void Main (string[] args) {
      //Connect local Redis service
      Jedis Jedis = new Jedis ("Lo Calhost ");
      System.out.println ("Connection to Server sucessfully");
      To see if the service is running
      System.out.println ("Server is running:" +jedis.ping ());
 }

Compile the Java program above to ensure that the path to the driver package is correct.

$javac Redisjava.java
$java redisjava
Connection to server sucessfully
server is Running:pong

Redis Java String Example

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.