代码拉取完成,页面将自动刷新
一个基于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 |
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。