Implementation:APIJSON APIJSON Demo RediSQLClient
| Knowledge Sources | |
|---|---|
| Domains | Database, Redis, Client_Library |
| Last Updated | 2026-10-14 00:00 GMT |
Overview
Concrete tool for communicating with a RediSQL instance over the Redis protocol, extending Jedis to execute RediSQL SQL commands.
Description
The RediSQLClient class extends redis.clients.jedis.Jedis to add RediSQL-specific command execution. It provides constructors for all Jedis connection variants (host/port, SSL, timeout, URI) and sends RediSQL commands by encoding command names and arguments through the Jedis sendCommand protocol. It supports creating databases, executing SQL statements, and retrieving results.
Usage
Use this class when you need to connect directly to a RediSQL-enabled Redis instance to execute SQL commands via the Redis wire protocol.
Code Reference
Source Location
- Repository: APIJSON_APIJSON_Demo
- File: APIJSON-Java-Server/APIJSONDemo-MultiDataSource-RediSQL/src/main/java/com/redbeardlab/redisql/client/RediSQLClient.java
- Lines: 1-196
Signature
public class RediSQLClient extends redis.clients.jedis.Jedis {
public RediSQLClient(String host, int port);
public RediSQLClient(String host, int port, boolean ssl);
// ... all Jedis constructors
public Object exec(String... args);
public Object createDb(String dbName);
public Object executeStatement(String dbName, String sql);
// ...
}
Import
import com.redbeardlab.redisql.client.RediSQLClient;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| host | String | Yes | Redis server hostname |
| port | int | Yes | Redis server port |
| dbName | String | No | RediSQL database name |
| sql | String | No | SQL statement to execute |
Outputs
| Name | Type | Description |
|---|---|---|
| exec() returns | Object | Raw RediSQL response |
| createDb() returns | Object | Database creation result |
| executeStatement() returns | Object | SQL execution result |
Usage Examples
Connect and Execute RediSQL
import com.redbeardlab.redisql.client.RediSQLClient;
// Connect to RediSQL instance
RediSQLClient client = new RediSQLClient("127.0.0.1", 6379);
// Create a database
client.createDb("mydb");
// Execute SQL
Object result = client.executeStatement("mydb", "CREATE TABLE test (id INT, name TEXT)");
System.out.println(result);