Git Product home page Git Product logo

redis-jdbc-driver's Introduction

Redis JDBC Driver

Apache licensed Latest Release CI

Type 4 JDBC driver based on Jedis that allows Java programs to connect to a Redis database.

This driver is embedded into DataGrip.

Get The Driver

Download

You can download the precompiled driver (jar) on the releases page.

Build

# Linux, MacOs
./gradlew jar

# Windows
gradlew.bat jar

You will find driver jar in build/libs

Get Started

// Load the driver
try {
  Class.forName("jdbc.RedisDriver");
} catch (ClassNotFoundException e) {
  e.printStackTrace();
  return;
}

// Create a connection
try (Connection connection = DriverManager.getConnection("jdbc:redis://localhost:6379/0", null, null)) {
  // Execute a query
  try (Statement statement = connection.createStatement()) {
    try (ResultSet resultSet = statement.executeQuery("SET key value")) {
      // Process the result set
      while (resultSet.next()) {
        String result = resultSet.getString("value");
        System.out.println("result: " + result);
      }
    }
  }
}

Connectivity

Server Status
Redis Standalone Supported
Redis Cluster Not supported yet
Redis Sentinel Not supported yet

Default host and port: 127.0.0.1:6379

URL templates

Redis Standalone

jdbc:redis://[[<user>:]<password>@][<host>[:<port>]][/<database>][?<property1>=<value>&<property2>=<value>&...]

Properties

Property Type Default Description
user String null
password String null
database Integer 0
connectionTimeout Integer 2000 Connection timeout in milliseconds.
socketTimeout Integer 2000 Socket timeout in milliseconds.
blockingSocketTimeout Integer 0 Socket timeout (in milliseconds) to use during blocking operation. Default is '0', which means to block forever.
clientName String null
ssl Boolean false Enable SSL.
verifyServerCertificate Boolean true Configure a connection that uses SSL but does not verify the identity of the server.

SSL

Set property ssl=true.

Pass arguments for your keystore and trust store:

-Djavax.net.ssl.trustStore=/path/to/client.truststore
-Djavax.net.ssl.trustStorePassword=password123
# If you're using client authentication:
-Djavax.net.ssl.keyStore=/path/to/client.keystore
-Djavax.net.ssl.keyStorePassword=password123

To disable server certificate verification set property verifyServerCertificate=false.

Commands Execution

Commands Status
Native Supported
RedisBloom Not supported yet
RediSearch Not supported yet
RedisGraph Not supported yet
RedisJSON Not supported yet
RedisTimeSeries Not supported yet

Classes

Interface Class Comment
java.sql.Driver jdbc.RedisDriver
java.sql.Connection jdbc.RedisConnection
java.sql.Statement jdbc.RedisStatement
java.sql.PreparedStatement jdbc.RedisPreparedStatement Dummy implementation: it is equivalent to jdbc.RedisStatement.
java.sql.DatabaseMetaData jdbc.RedisDatabaseMetaData Minimal implementation: it does not contain information about database objects.
java.sql.ResultSet jdbc.resultset.RedisResultSetBase
java.sql.ResultSetMetaData jdbc.resultset.RedisResultSetMetaData Partial implementation: it contains only information about columns.

References

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.