一个基于Jedis的Redis JDBC驱动。
URL:
在项目中添加如下依赖:
<dependency>
<groupId>com.itmuch.redis</groupId>
<artifactId>redis-jdbc</artifactId>
<version>0.0.1</version>
</dependency>
Class.forName("com.itmuch.redis.jdbc.redis.RedisDriver");
Connection connection = DriverManager.getConnection(
"jdbc:redis://localhost:6379/0",
properties
);
Statement statement = connection.createStatement();
connection.setSchema("11");
ResultSet rs = statement.executeQuery("get a");
while (rs.next()) {
String string = rs.getString(0);
System.out.println(string);
}
其中,properties中的key可如下表所示:
| key | defaultValue | description |
|---|---|---|
| user | null | the user of Redis |
| password | null | the password of user |
| ssl | false | whether to use ssl |
| timeout | 1000 | Jedis timeout |
Class.forName("com.itmuch.redis.jdbc.cluster.RedisClusterDriver");
Connection connection = DriverManager.getConnection(
"jdbc:redis-cluster:///localhost:6379;localhost:6380;localhost:6381",
properties
);
Statement statement = connection.createStatement();
connection.setSchema("11");
ResultSet rs = statement.executeQuery("get a");
while (rs.next()) {
String string = rs.getString(0);
System.out.println(string);
}
其中,properties可如下表所示:
| key | defaultValue | description |
|---|---|---|
| user | null | the user of Redis |
| password | null | the password of user |
| ssl | false | whether to use ssl |
| timeout | 1000 | Jedis timeout |
| maxAttempts | 5 | Jedis maxAttempts |
$ claude mcp add redis-jdbc \
-- python -m otcore.mcp_server <graph>