DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • How to Introduce a New API Quickly Using Micronaut
  • How to Merge HTML Documents in Java
  • Designing a Java Connector for Software Integrations
  • Jakarta NoSQL 1.0: A Way To Bring Java and NoSQL Together

Trending

  • Go 1.24+ Native FIPS Support for Easier Compliance
  • Advancing Your Software Engineering Career in 2025
  • Using Java Stream Gatherers To Improve Stateful Operations
  • Implementing API Design First in .NET for Efficient Development, Testing, and CI/CD
  1. DZone
  2. Data Engineering
  3. Databases
  4. Implementing DAO Design Pattern in Jedis Using Java API

Implementing DAO Design Pattern in Jedis Using Java API

In this article, we are going to learn the DAO design pattern and the implementation in the Jedis java client.

By 
Tiruvenkatasamy Baskaran user avatar
Tiruvenkatasamy Baskaran
·
Dec. 02, 20 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
7.5K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, we are going to learn the DAO design pattern and the implementation in the Jedis java client. The DAO pattern is implemented as a layer between the Client application and the Database. The client application need not depend on the underlying database interaction API (Low-level). The data being stored in the Redis database is modeled as a Domain object (POJO class). It will have only getter and setter methods. The client application knows only the domain object and the high-level API.

Prerequisites

  • Eclipse (any version) with Maven capabilities
  • Java 8+
  • Junit
  • Redis and Jedis

Installing Redis Server on Windows

  1. Click on the link: https://github.com/dmajkic/redis/downloads
  2. Download Redis-2.4.5-win32-win64.zip file
  3. Unzip the file and go to the 64bit folder. There you can find redis-server.exe
  4. To start the Redis server, execute the redis-server.exe file.

Installing Eclipse-IDE on Windows

  1. Click on the link: https://www.eclipse.org/downloads/download.php?file=/oomph/epp/2020-09/R/eclipse-inst-jre-win64.exe
  2. Download the eclipse-inst-jre-win64.exe file and run the eclipse installer.

    

    3. Select Eclipse IDE for Eclipse committers and install


Creating a Maven Project in Eclipse IDE

      1. Open the Eclipse IDE

      2. Go to File  > New > Project

      

      3. Go to Maven -> Maven Project and click Next.

      

      4. Select your workspace location and click Next

    

      5. Select quick start maven archetype and click Next

     

      6. Enter Group Id, Artifact Id, and package name.


  • Group Id: Fill a groupId for the project of your choice.
  • Artifact Id: Fill artifactId for the project of your choice.
  • Package: java package structure of your choice

       7. The above process will create a project structure like below.


8. Create packages like com.example.demo.dao, com.example.demo.model and com.example.demo.util under src/test/java folder


9. Place the SiteDaoRedisImplTest.java file in com.example.demo package.          

Java
 




x
149


 
1
package com.example.demo;
2

          
3

          
4
import static org.hamcrest.MatcherAssert.assertThat;
5
import static org.hamcrest.Matchers.empty;
6
import static org.hamcrest.Matchers.is;
7
import static org.hamcrest.Matchers.nullValue;
8
import static org.junit.Assert.assertEquals;
9

          
10
import java.util.HashSet;
11
import java.util.Map;
12
import java.util.Set;
13

          
14
import org.junit.After;
15
import org.junit.AfterClass;
16
import org.junit.Before;
17
import org.junit.BeforeClass;
18
import org.junit.Test;
19

          
20
import com.example.demo.dao.SiteDaoRedisImpl;
21
import com.example.demo.model.Site;
22
import com.example.demo.util.HostPort;
23
import com.example.demo.util.RedisSchema;
24
import com.example.demo.util.TestKeyManager;
25

          
26
import redis.clients.jedis.Jedis;
27
import redis.clients.jedis.JedisPool;
28
import redis.clients.jedis.JedisPoolConfig;
29

          
30
public class SiteDaoRedisImplTest {
31

          
32
    private static JedisPool jedisPool;
33
    private static Jedis jedis;
34
    private static TestKeyManager keyManager;
35
    private Set<Site> sites;
36

          
37
    @BeforeClass
38
    public static void setUp() throws Exception {
39
        String password = HostPort.getRedisPassword();
40

          
41
        if (password.length() > 0) {
42
            jedisPool = new JedisPool(new JedisPoolConfig(), HostPort.getRedisHost(), HostPort.getRedisPort(), 2000, password);
43
        } else {
44
            jedisPool = new JedisPool(HostPort.getRedisHost(), HostPort.getRedisPort());
45
        }
46

          
47
        jedis = new Jedis(HostPort.getRedisHost(), HostPort.getRedisPort());
48

          
49
        if (password.length() > 0) {
50
            jedis.auth(password);
51
        }
52

          
53
        keyManager = new TestKeyManager("test");
54
    }
55

          
56
    @AfterClass
57
    public static void tearDown() {
58
        jedisPool.destroy();
59
        jedis.close();
60
    }
61

          
62
    @After
63
    public void flush() {
64
        keyManager.deleteKeys(jedis);
65
    }
66

          
67
    @Before
68
    public void generateData() {
69
        sites = new HashSet<>();
70
        sites.add(new Site(1, 4.5, 3, "123 Willow St.",
71
                "Oakland", "CA", "94577" ));
72
        sites.add(new Site(2, 3.0, 2, "456 Maple St.",
73
                 "Oakland", "CA", "94577" ));
74
        sites.add(new Site(3, 4.0, 3, "789 Oak St.",
75
                 "Oakland", "CA", "94577" ));
76
    }
77

          
78
    /**
79
     * Challenge #0 Part 1. This challenge is explained in
80
     * the video "How to Solve a Sample Challenge"
81
     */
82
    @Test
83
    public void findByIdWithExistingSite() {
84
        SiteDaoRedisImpl dao = new SiteDaoRedisImpl(jedisPool);
85
        Site site = new Site(4L, 5.5, 4, "910 Pine St.",
86
                "Oakland", "CA", "94577");
87
        dao.insert(site);
88
        Site storedSite = dao.findById(4L);
89
        System.out.println(storedSite);
90
        System.out.println(site);
91
        assertThat(storedSite, is(site));
92
    }
93

          
94
    /**
95
     * Challenge #0 Part 2. This challenge is explained in
96
     * the video "How to Solve a Sample Challenge"
97
     */
98
    @Test
99
    public void findByIdWithMissingSite() {
100
        SiteDaoRedisImpl dao = new SiteDaoRedisImpl(jedisPool);
101
        System.out.println(dao.findById(4L));
102
        assertThat(dao.findById(4L), is(nullValue()));
103
    }
104

          
105
    /**
106
     * Challenge #1 Part 1. Use this test case to
107
     * implement the challenge in Chapter 1.
108
     */
109
    
110
    @Test
111
    public void findAllWithMultipleSites() {
112
        SiteDaoRedisImpl dao = new SiteDaoRedisImpl(jedisPool);
113
        // Insert all sites
114
        for (Site site : sites) {
115
            dao.insert(site);
116
            System.out.println(site);
117
        }
118
        System.out.println("----------------------------------");
119
        assertThat(dao.findAll(), is(sites));
120
    }
121

          
122
    /**
123
     * Challenge #1 Part 2. Use this test case to
124
     * implement the challenge in Chapter 1.
125
     */
126
    
127
    @Test
128
    public void findAllWithEmptySites() {
129
        SiteDaoRedisImpl dao = new SiteDaoRedisImpl(jedisPool);
130
        assertThat(dao.findAll(), is(empty()));
131
    }
132

          
133
    @Test
134
    public void insert() {
135
        SiteDaoRedisImpl dao = new SiteDaoRedisImpl(jedisPool);
136
        Site site = new Site(4, 5.5, 4, "910 Pine St.",
137
                "Oakland", "CA", "94577");
138
        dao.insert(site);
139

          
140
        Map<String, String> siteFields = jedis.hgetAll(RedisSchema.getSiteHashKey(4L));
141
        System.out.println(siteFields);
142
        System.out.println(site.toMap());
143
        assertEquals(siteFields, site.toMap());
144

          
145
        assertThat(jedis.sismember(RedisSchema.getSiteIDsKey(), RedisSchema.getSiteHashKey(4L)),
146
                is(true));
147
    }
148
}
149

          



10. Add the SiteDao.java file in com.example.demo.dao package.

Java
 




xxxxxxxxxx
1
12


 
1
package com.example.demo.dao;
2

          
3
import java.util.Set;
4

          
5
import com.example.demo.model.Site;
6

          
7
public interface SiteDao {
8
    void insert(Site site);
9
    Site findById(long id);
10
    Set<Site> findAll();
11
}
12

          


 

 11. Add the SiteDaoRedisImpl.java file in com.example.demo.dao package  

Java
 




xxxxxxxxxx
1
65


 
1
package com.example.demo.dao;
2

          
3
import java.util.HashSet;
4
import java.util.Map;
5
import java.util.Set;
6

          
7
import com.example.demo.model.Site;
8
import com.example.demo.util.RedisSchema;
9

          
10
import redis.clients.jedis.Jedis;
11
import redis.clients.jedis.JedisPool;
12

          
13

          
14

          
15
public class SiteDaoRedisImpl implements SiteDao {
16
    private final JedisPool jedisPool;
17

          
18
    public SiteDaoRedisImpl(JedisPool jedisPool) {
19
        this.jedisPool = jedisPool;
20
    }
21

          
22
    // When we insert a site, we set all of its values into a single hash.
23
    // We then store the site's id in a set for easy access.
24
    @Override
25
    public void insert(Site site) {
26
        try (Jedis jedis = jedisPool.getResource()) {
27
            String hashKey = RedisSchema.getSiteHashKey(site.getId());
28
            String siteIdKey = RedisSchema.getSiteIDsKey();
29
            jedis.hmset(hashKey, site.toMap());
30
            jedis.sadd(siteIdKey, hashKey);
31
        }
32
    }
33

          
34
    @Override
35
    public Site findById(long id) {
36
        try(Jedis jedis = jedisPool.getResource()) {
37
            String key = RedisSchema.getSiteHashKey(id);
38
            Map<String, String> fields = jedis.hgetAll(key);
39
                        
40
            if (fields == null || fields.isEmpty()) {
41
                return null;
42
            } else {
43
                return new Site(fields);
44
            }
45
        }
46
    }
47

          
48
    // Challenge #1
49
    @Override
50
    public Set<Site> findAll() {
51
        try (Jedis jedis = jedisPool.getResource()) {
52
            Set<String> keys = jedis.keys("test:sites:info:*");
53
            Set<Site> sites = new HashSet<>(keys.size());
54
            for (String key : keys) {
55
                Map<String, String> site = jedis.hgetAll(key);
56
                if (!site.isEmpty()) {
57
                    sites.add(new Site(site));
58
                }
59
            }
60
            System.out.println(sites);
61
            return sites;
62
        }
63
    }
64
}
65

          



12. Add HostPort.java,KeyHelper.java,MetricUnit.java,RedisSchema.java    and TaskKeyManager.java in com.example.demo.util package

Java
 




xxxxxxxxxx
1
20


 
1
package com.example.demo.util;
2

          
3
public class HostPort {
4
    final private static String defaultHost = "localhost";
5
    final private static Integer defaultPort = 6379;
6
    final private static String defaultPassword = "";
7

          
8
    public static String getRedisHost() {
9
        return defaultHost;
10
    }
11

          
12
    public static Integer getRedisPort() {
13
        return defaultPort;
14
    }
15

          
16
    public static String getRedisPassword() {
17
        return defaultPassword;
18
    }
19
}
20

          


Java
 




xxxxxxxxxx
1
25


 
1
package com.example.demo.util;
2

          
3
public class KeyHelper {
4

          
5
    final private static String defaultPrefix = "app";
6

          
7
    private static String prefix = null;
8

          
9
    public static void setPrefix(String keyPrefix) {
10
        prefix = keyPrefix;
11
    }
12

          
13
    public static String getKey(String key) {
14
        return getPrefix() + ":" + key;
15
    }
16

          
17
    public static String getPrefix() {
18
        if (prefix != null) {
19
            return prefix;
20
        } else {
21
            return defaultPrefix;
22
        }
23
    }
24
}
25

          


Java
 




xxxxxxxxxx
1
18


 
1
package com.example.demo.util;
2

          
3
public enum MetricUnit {
4
    WHGenerated("whG"),
5
    WHUsed("whU"),
6
    TemperatureCelsius("tempC");
7

          
8
    private final String shortName;
9

          
10
    MetricUnit(String shortName) {
11
        this.shortName = shortName;
12
    }
13

          
14
    public String getShortName() {
15
        return shortName;
16
    }
17
}
18

          


Java
 




xxxxxxxxxx
1
93


 
1
package com.example.demo.util;
2

          
3
import java.time.ZonedDateTime;
4

          
5
/**
6
 * Methods to generate key names for Redis
7
 * data structures. These key names are used
8
 * by the RedisDaoImpl classes. This class therefore
9
 * contains a reference to all possible key names
10
 * used by this application.
11
 */
12
public class RedisSchema {
13
    // sites:info:[siteId]
14
    // Redis type: hash
15
    public static String getSiteHashKey(long siteId) {
16
        return KeyHelper.getKey("sites:info:" + siteId);
17
    }
18

          
19
    // sites:ids
20
    // Redis type: set
21
    public static String getSiteIDsKey() {
22
        return KeyHelper.getKey("sites:ids");
23
    }
24

          
25
    // sites:stats:[year-month-day]:[siteId]
26
    // Redis type: sorted set
27
    public static String getSiteStatsKey(Long siteId, ZonedDateTime dateTime) {
28
        return KeyHelper.getKey("sites:stats:" +
29
                getYearMonthDay(dateTime) + ":" +
30
                String.valueOf(siteId));
31
    }
32

          
33
    // limiter:[name]:[duration]:[maxHits]
34
    // Redis type: string of type integer
35
    static String getRateLimiterKey(String name, int minuteBlock,
36
                                    long maxHits) {
37
        return KeyHelper.getKey("limiter:" +
38
                name + ":" +
39
                String.valueOf(minuteBlock) + ":" +
40
                String.valueOf(maxHits));
41
    }
42

          
43
    // sites:geo
44
    // Redis type: geo
45
    static String getSiteGeoKey() {
46
        return KeyHelper.getKey("sites:geo");
47
    }
48

          
49
    // sites:capacity:ranking
50
    // Redis type: sorted set
51
    static String getCapacityRankingKey() {
52
        return KeyHelper.getKey("sites:capacity:ranking");
53
    }
54

          
55
    // metric:[unit-name]:[year-month-day]:[siteId]
56
    // Redis type: sorted set
57
    static String getDayMetricKey(Long siteId, MetricUnit unit,
58
                                  ZonedDateTime dateTime) {
59
        return KeyHelper.getPrefix() +
60
                ":metric:" +
61
                unit.getShortName() +
62
                ":" +
63
                getYearMonthDay(dateTime) +
64
                ":" +
65
                String.valueOf(siteId);
66
    }
67

          
68
    // sites:feed
69
    // Redis type: stream
70
    static String getGlobalFeedKey() {
71
        return KeyHelper.getKey("sites:feed");
72
    }
73

          
74
    // sites:feed:[siteId]
75
    // Redis type: stream
76
    static String getFeedKey(long siteId) {
77
        return KeyHelper.getKey("sites:feed:" + String.valueOf(siteId));
78
    }
79

          
80
    // Return the year and month in the form YEAR-MONTH-DAY
81
    private static String getYearMonthDay(ZonedDateTime dateTime) {
82
        return String.valueOf(dateTime.getYear()) + "-" +
83
                String.valueOf(dateTime.getMonthValue()) + "-" +
84
                String.valueOf(dateTime.getDayOfMonth());
85
    }
86

          
87
    // sites:ts:[siteId]:[unit]
88
    // Redis type: RedisTimeSeries
89
    static String getTSKey(Long siteId, MetricUnit unit) {
90
        return KeyHelper.getKey("sites:ts:" + String.valueOf(siteId) + ":" + unit.toString());
91
    }
92
}
93

          


Java
 




xxxxxxxxxx
1
31


 
1
package com.example.demo.util;
2

          
3
import redis.clients.jedis.Jedis;
4

          
5
import java.util.Set;
6

          
7

          
8

          
9
// Provides a consistent key prefix for tests and
10
// a method for cleaning up these keys.
11
public class TestKeyManager {
12

          
13
    private String prefix;
14

          
15
    public TestKeyManager(String prefix) {
16
        KeyHelper.setPrefix(prefix);
17
        this.prefix = prefix;
18
    }
19

          
20
    public void deleteKeys(Jedis jedis) {
21
        Set<String> keysToDelete = jedis.keys(getKeyPattern());
22
        for (String key : keysToDelete) {
23
           jedis.del(key);
24
        }
25
    }
26

          
27
    private String getKeyPattern() {
28
        return prefix + ":*";
29
    }
30
}
31

          



13. Replace the pom.xml with the below content.

XML
 
xxxxxxxxxx
1
213


 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project
3
        xmlns="http://maven.apache.org/POM/4.0.0"
4
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
6

          
7
    <modelVersion>4.0.0</modelVersion>
8
    <prerequisites>
9
        <maven>3.0.0</maven>
10
    </prerequisites>
11

          
12
    <groupId>JedisDAODemo</groupId>
13
    <artifactId>JedisDAODemo</artifactId>
14
    <version>1.0</version>
15
    <packaging>jar</packaging>
16

          
17
    <name>JedisDAODemo</name>
18

          
19
    <properties>
20
        <redis.host>localhost</redis.host>
21
        <redis.port>6379</redis.port>
22
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24
        <dropwizard.version>1.3.8</dropwizard.version>
25
        <mainClass>com.example.demo.RediSolarApplication</mainClass>
26
    </properties>
27

          
28
    <dependencyManagement>
29
        <dependencies>
30
            <dependency>
31
                <groupId>io.dropwizard</groupId>
32
                <artifactId>dropwizard-bom</artifactId>
33
                <version>${dropwizard.version}</version>
34
                <type>pom</type>
35
                <scope>import</scope>
36
            </dependency>
37
        </dependencies>
38
    </dependencyManagement>
39

          
40
    <dependencies>
41
        <dependency>
42
            <groupId>com.google.inject</groupId>
43
            <artifactId>guice</artifactId>
44
            <version>4.2.2</version>
45
        </dependency>
46
        <dependency>
47
            <groupId>io.dropwizard</groupId>
48
            <artifactId>dropwizard-core</artifactId>
49
        </dependency>
50
        <dependency>
51
            <groupId>io.dropwizard</groupId>
52
            <artifactId>dropwizard-assets</artifactId>
53
        </dependency>
54
        <dependency>
55
            <groupId>io.dropwizard</groupId>
56
            <artifactId>dropwizard-testing</artifactId>
57
        </dependency>
58
        <dependency>
59
            <groupId>redis.clients</groupId>
60
            <artifactId>jedis</artifactId>
61
            <version>3.1.0-m3</version>
62
        </dependency>
63
        <dependency>
64
            <groupId>com.redislabs</groupId>
65
            <artifactId>jredistimeseries</artifactId>
66
            <version>0.9.0</version>
67
        </dependency>
68
        <dependency>
69
            <groupId>javax.xml.bind</groupId>
70
            <artifactId>jaxb-api</artifactId>
71
            <version>2.2.11</version>
72
        </dependency>
73
        <dependency>
74
            <groupId>com.sun.xml.bind</groupId>
75
            <artifactId>jaxb-core</artifactId>
76
            <version>2.2.11</version>
77
        </dependency>
78
        <dependency>
79
            <groupId>com.sun.xml.bind</groupId>
80
            <artifactId>jaxb-impl</artifactId>
81
            <version>2.2.11</version>
82
        </dependency>
83
        <dependency>
84
            <groupId>javax.activation</groupId>
85
            <artifactId>activation</artifactId>
86
            <version>1.1.1</version>
87
        </dependency>
88
        <dependency>
89
            <groupId>junit</groupId>
90
            <artifactId>junit</artifactId>
91
            <version>4.12</version>
92
            <scope>test</scope>
93
        </dependency>
94
        <dependency>
95
            <groupId>org.hamcrest</groupId>
96
            <artifactId>hamcrest-all</artifactId>
97
            <version>1.3</version>
98
            <scope>test</scope>
99
        </dependency>
100
        <dependency>
101
            <groupId>org.mockito</groupId>
102
            <artifactId>mockito-all</artifactId>
103
            <version>1.9.5</version>
104
            <scope>test</scope>
105
        </dependency>
106
    </dependencies>
107

          
108
    <build>
109
        <plugins>
110
            <plugin>
111
                <groupId>org.codehaus.mojo</groupId>
112
                <artifactId>properties-maven-plugin</artifactId>
113
                <version>1.0.0</version>
114
                <executions>
115
                    <execution>
116
                        <phase>initialize</phase>
117
                        <goals>
118
                            <goal>read-project-properties</goal>
119
                        </goals>
120
                        <configuration>
121
                            <files>
122
                                <file>pom.xml</file>
123
                            </files>
124
                        </configuration>
125
                    </execution>
126
                </executions>
127
            </plugin>
128
            <plugin>
129
                <artifactId>maven-shade-plugin</artifactId>
130
                <version>2.4.1</version>
131
                <configuration>
132
                    <createDependencyReducedPom>false</createDependencyReducedPom>
133
                    <transformers>
134
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
135
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
136
                            <mainClass>${mainClass}</mainClass>
137
                        </transformer>
138
                    </transformers>
139
                    <!-- exclude signed Manifests -->
140
                    <filters>
141
                        <filter>
142
                            <artifact>*:*</artifact>
143
                            <excludes>
144
                                <exclude>META-INF/*.SF</exclude>
145
                                <exclude>META-INF/*.DSA</exclude>
146
                                <exclude>META-INF/*.RSA</exclude>
147
                            </excludes>
148
                        </filter>
149
                    </filters>
150
                </configuration>
151
                <executions>
152
                    <execution>
153
                        <phase>package</phase>
154
                        <goals>
155
                            <goal>shade</goal>
156
                        </goals>
157
                    </execution>
158
                </executions>
159
            </plugin>
160
            <plugin>
161
                <artifactId>maven-jar-plugin</artifactId>
162
                <version>3.0.2</version>
163
                <configuration>
164
                    <archive>
165
                        <manifest>
166
                            <addClasspath>true</addClasspath>
167
                            <mainClass>${mainClass}</mainClass>
168
                        </manifest>
169
                    </archive>
170
                </configuration>
171
            </plugin>
172
            <plugin>
173
                <artifactId>maven-compiler-plugin</artifactId>
174
                <version>3.6.1</version>
175
                <configuration>
176
                    <source>1.8</source>
177
                    <target>1.8</target>
178
                </configuration>
179
            </plugin>
180
            <plugin>
181
                <artifactId>maven-source-plugin</artifactId>
182
                <version>3.0.1</version>
183
                <executions>
184
                    <execution>
185
                        <id>attach-sources</id>
186
                        <goals>
187
                            <goal>jar</goal>
188
                        </goals>
189
                    </execution>
190
                </executions>
191
            </plugin>
192
        </plugins>
193
    </build>
194

          
195
    <reporting>
196
        <plugins>
197
            <plugin>
198
                <artifactId>maven-project-info-reports-plugin</artifactId>
199
                <version>2.8.1</version>
200
                <configuration>
201
                    <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
202
                    <dependencyDetailsEnabled>false</dependencyDetailsEnabled>
203
                </configuration>
204
            </plugin>
205
            <plugin>
206
                <artifactId>maven-javadoc-plugin</artifactId>
207
                <version>2.10.3</version>
208
            </plugin>
209
        </plugins>
210
    </reporting>
211
</project>
212

          
213

          


Running the Code

  1. Build the Maven project and run the test case as shown below.

       2. Check the test result.

Now, we learned the DAO pattern to perform database operations without knowing the low-level API through the Jedis java client application.

Further, this use case can be adapted according to your requirements.

Feel free to ask any questions.

Decentralized autonomous organization API Java (programming language) Jedi (game engine) Design

Opinions expressed by DZone contributors are their own.

Related

  • How to Introduce a New API Quickly Using Micronaut
  • How to Merge HTML Documents in Java
  • Designing a Java Connector for Software Integrations
  • Jakarta NoSQL 1.0: A Way To Bring Java and NoSQL Together

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!