This commit is contained in:
parent
98d5c161c5
commit
abf27bae39
|
@ -0,0 +1,35 @@
|
|||
package org.budo.redis.jdbc.driver;
|
||||
|
||||
import org.budo.redis.jdbc.driver.beetlsql.BeetlSqlTest;
|
||||
import org.budo.redis.jdbc.driver.hibernate.HibernateKeyTest;
|
||||
import org.budo.redis.jdbc.driver.jdbc.JdbcTest;
|
||||
import org.budo.redis.jdbc.driver.mybatis.MybatisHashTest;
|
||||
import org.budo.redis.jdbc.driver.mybatis.MybatisKeyTest;
|
||||
import org.budo.redis.jdbc.driver.mybatis.MybatisListTest;
|
||||
import org.budo.redis.jdbc.driver.mybatis.MybatisSetTest;
|
||||
import org.budo.redis.jdbc.driver.mybatis.MybatisSortedSetTest;
|
||||
import org.budo.redis.jdbc.driver.mybatis.MybatisStringTest;
|
||||
import org.budo.redis.jdbc.driver.statement.HashTest;
|
||||
import org.budo.redis.jdbc.driver.statement.KeyTest;
|
||||
import org.budo.redis.jdbc.driver.statement.ListTest;
|
||||
import org.budo.redis.jdbc.driver.statement.MysqlTest;
|
||||
import org.budo.redis.jdbc.driver.statement.ScriptTest;
|
||||
import org.budo.redis.jdbc.driver.statement.ServerTest;
|
||||
import org.budo.redis.jdbc.driver.statement.SetTest;
|
||||
import org.budo.redis.jdbc.driver.statement.SortedSetTest;
|
||||
import org.budo.redis.jdbc.driver.statement.StringTest;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Suite;
|
||||
import org.junit.runners.Suite.SuiteClasses;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
@RunWith(Suite.class)
|
||||
@SuiteClasses({ //
|
||||
BeetlSqlTest.class, //
|
||||
HibernateKeyTest.class, //
|
||||
JdbcTest.class, // ,
|
||||
MybatisHashTest.class, MybatisKeyTest.class, MybatisListTest.class, MybatisSetTest.class, MybatisSortedSetTest.class, MybatisStringTest.class, //
|
||||
HashTest.class, KeyTest.class, ListTest.class, SetTest.class, SortedSetTest.class, StringTest.class, ScriptTest.class, MysqlTest.class, ServerTest.class })
|
||||
public class AllTest {}
|
|
@ -0,0 +1,92 @@
|
|||
package org.budo.redis.jdbc.driver;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.budo.mybatis.dao.MybatisDao;
|
||||
import org.budo.mybatis.dao.factory.MybatisDaoFactory;
|
||||
import org.budo.support.javax.sql.util.ResultSetUtil;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mybatis.spring.SqlSessionFactoryBean;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:spring.xml")
|
||||
public class BaseTest {
|
||||
@Resource(name = "dbtbl_0") // dbtbl_0 // shardingDataSource
|
||||
protected DataSource dataSource;
|
||||
|
||||
private Map<PreparedStatement, Connection> statementConnectionMap = new HashMap<PreparedStatement, Connection>();
|
||||
|
||||
protected PreparedStatement prepareStatement(String sql) {
|
||||
try {
|
||||
Connection connection = dataSource.getConnection();
|
||||
PreparedStatement prepareStatement = connection.prepareStatement(sql);
|
||||
statementConnectionMap.put(prepareStatement, connection);
|
||||
return prepareStatement;
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void executeQueryAndPrintResultSet(PreparedStatement preparedStatement) {
|
||||
try {
|
||||
ResultSet resultSet = preparedStatement.executeQuery();
|
||||
System.err.println("preparedStatement=" + preparedStatement);
|
||||
List<Map<String, Object>> mapList = ResultSetUtil.toMapList(resultSet);
|
||||
System.err.println("mapList.size=" + mapList.size());
|
||||
|
||||
for (Map<String, Object> map : mapList) {
|
||||
System.err.println(map);
|
||||
}
|
||||
|
||||
resultSet.close();
|
||||
preparedStatement.close();
|
||||
statementConnectionMap.get(preparedStatement).close();
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void executeUpdateAndPrint(PreparedStatement preparedStatement) {
|
||||
try {
|
||||
int executeUpdate = preparedStatement.executeUpdate();
|
||||
System.err.println("executeUpdate=" + executeUpdate);
|
||||
preparedStatement.close();
|
||||
statementConnectionMap.get(preparedStatement).close();
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected MybatisDao mybatisDao() {
|
||||
try {
|
||||
SqlSessionFactoryBean sessionFactoryBean = new SqlSessionFactoryBean();
|
||||
sessionFactoryBean.setDataSource(dataSource);
|
||||
SqlSessionFactory sqlSessionFactory = sessionFactoryBean.getObject();
|
||||
|
||||
MybatisDaoFactory mybatisDaoFactory = new MybatisDaoFactory();
|
||||
mybatisDaoFactory.setSqlSessionFactory(sqlSessionFactory);
|
||||
MybatisDao mybatisDao = mybatisDaoFactory.getObject();
|
||||
return mybatisDao;
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void _() {}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.budo.redis.jdbc.driver.beetlsql;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.beetl.sql.core.ConnectionSource;
|
||||
import org.beetl.sql.core.DefaultConnectionSource;
|
||||
import org.beetl.sql.core.SQLManager;
|
||||
import org.beetl.sql.core.SQLReady;
|
||||
import org.beetl.sql.core.db.MySqlStyle;
|
||||
import org.budo.redis.jdbc.driver.BaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class BeetlSqlTest extends BaseTest {
|
||||
@Test
|
||||
public void beetlSql() {
|
||||
ConnectionSource connectionSource = new DefaultConnectionSource(dataSource, null);
|
||||
MySqlStyle sqlStyle = new MySqlStyle();
|
||||
SQLManager sqlManager = new SQLManager(sqlStyle, connectionSource);
|
||||
SQLReady sqlReady = new SQLReady("SELECT KEYS(?)", "*aa*");
|
||||
sqlManager.execute(sqlReady, Object.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void KEYS() {
|
||||
ConnectionSource connectionSource = new DefaultConnectionSource(dataSource, null);
|
||||
MySqlStyle sqlStyle = new MySqlStyle();
|
||||
SQLManager sqlManager = new SQLManager(sqlStyle, connectionSource);
|
||||
List<Map> maps = sqlManager.execute(new SQLReady("SELECT KEYS('*a*')"), Map.class);
|
||||
System.err.println(maps);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package org.budo.redis.jdbc.driver.hibernate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class HibernateKeyTest {
|
||||
@Resource
|
||||
DataSource dataSource;
|
||||
|
||||
@Test
|
||||
public void hibernate() {
|
||||
String sql = "SELECT KEYS(:key)";
|
||||
SQLQuery sqlQuery = this.sqlQuery(sql);
|
||||
sqlQuery.setString("key", "*");
|
||||
List list = sqlQuery.list();
|
||||
System.err.println("hibernate list = " + list);
|
||||
}
|
||||
|
||||
private SQLQuery sqlQuery(String sql) {
|
||||
Configuration configuration = new Configuration();
|
||||
configuration.configure();
|
||||
|
||||
SessionFactory sessionFactory = configuration.buildSessionFactory();
|
||||
Session openSession = sessionFactory.openSession();
|
||||
SQLQuery sqlQuery = openSession.createSQLQuery(sql);
|
||||
return sqlQuery;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
package org.budo.redis.jdbc.driver.jdbc;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
|
||||
import org.budo.redis.jdbc.driver.BaseTest;
|
||||
import org.budo.support.lang.util.IoUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class JdbcTest extends BaseTest {
|
||||
@Test
|
||||
public void SELECT_KEYS() throws Throwable {
|
||||
String sql = "SELECT key FROM session WHERE key LIKE ?";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "*providers*");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SELECT_VALUE_GET() throws Throwable {
|
||||
String sql = "SELECT value FROM session WHERE key=?";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaa");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void DEL_KEY_2() throws Throwable {
|
||||
String sql = "DELETE\r\n" + " FROM\r\n" + " del_session\r\n" + " WHERE\r\n" + " KEY = 'shiro-session-redis-a82baa1be45a4c06a0eab35c7bd3bfae'";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void DEL_KEY() throws Throwable {
|
||||
String sql = "DELETE FROM session WHERE key=?";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "del-key");
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void UPDATE_SET_2() throws Throwable {
|
||||
String sql = "UPDATE session SET expire=? WHERE key=?";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setInt(1, 9);
|
||||
preparedStatement.setString(2, "-----");
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void UPDATE_SET_1() throws Throwable {
|
||||
String sql = "UPDATE session SET value=? WHERE key=?";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "-----");
|
||||
preparedStatement.setString(2, "-----");
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void UPDATE_SET() throws Throwable {
|
||||
String sql = "UPDATE session SET a = b WHERE SET(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "-----");
|
||||
preparedStatement.setString(2, "-----");
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void UPDATE_SET_VALUE() throws Throwable {
|
||||
String sql = "UPDATE redis SET value = 'value-3' WHERE key = 'key-3'";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void UPDATE_SET_EXPIRE() throws Throwable {
|
||||
String sql = "UPDATE redis SET expire = 99999 WHERE key = 'key-3'";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void UPDATE_SET_EXPIRE_2() throws Throwable {
|
||||
String sql = "UPDATE redis SET expire = ? WHERE key = 'key-3'";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setInt(1, 9999);
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void UPDATE_SET_EXPIRE_3() throws Throwable {
|
||||
String sql = "UPDATE redis SET expire = 99999 WHERE key = ?";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "key-3");
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void DELETE_DEL() throws Throwable {
|
||||
String sql = "DELETE FROM session WHERE DEL(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "-----");
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statementExecute() throws Throwable {
|
||||
String sql = "SELECT KEYS('*') FROM ssss";
|
||||
Connection connection = dataSource.getConnection();
|
||||
Statement statement = connection.createStatement();
|
||||
statement.execute(sql);
|
||||
statement.close();
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statementExecuteUpdate() throws Throwable {
|
||||
String sql = "DELETE FROM del_session WHERE DEL('12345')";
|
||||
Connection connection = dataSource.getConnection();
|
||||
Statement statement = connection.createStatement();
|
||||
statement.executeUpdate(sql);
|
||||
statement.close();
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void statementExecuteQuery() throws Throwable {
|
||||
String sql = "SELECT KEYS('*')";
|
||||
Connection connection = dataSource.getConnection();
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet resultSet = statement.executeQuery(sql);
|
||||
while (resultSet.next()) {
|
||||
System.err.println("characterStream=" + IoUtil.toString(resultSet.getCharacterStream("keys")));
|
||||
}
|
||||
|
||||
resultSet.close();
|
||||
statement.close();
|
||||
connection.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package org.budo.redis.jdbc.driver.mybatis;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.budo.redis.jdbc.driver.BaseTest;
|
||||
import org.budo.support.lang.util.MapUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class MybatisHashTest extends BaseTest {
|
||||
@Test
|
||||
public void HGETALL() {
|
||||
String sql = "SELECT HGETALL(#{key}) FROM consumers";
|
||||
Map<String, Object> parameter = MapUtil.stringObjectMap("key", "com.ticket.api.service.IWorkTimeService/consumers");
|
||||
Map map = this.mybatisDao().findBySql(Map.class, sql, parameter);
|
||||
System.err.println(JSON.toJSONString(map));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package org.budo.redis.jdbc.driver.mybatis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.budo.redis.jdbc.driver.BaseTest;
|
||||
import org.budo.support.dao.page.Page;
|
||||
import org.budo.support.lang.util.MapUtil;
|
||||
import org.budo.time.Time;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class MybatisKeyTest extends BaseTest {
|
||||
@Test
|
||||
public void DEL() {
|
||||
String sql = "SELECT DEL(#{keys})";
|
||||
Map<String, Object> parameter = MapUtil.stringObjectMap("keys", new String[] { "k1", "k2" });
|
||||
|
||||
Integer del = this.mybatisDao().updateBySql(sql, parameter);
|
||||
System.err.println(del);
|
||||
|
||||
Integer updateBySql = this.mybatisDao().updateBySql(sql, parameter);
|
||||
System.err.println(updateBySql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void EXISTS() throws Throwable {
|
||||
String sql = "SELECT EXISTS(#{key})";
|
||||
Map<String, Object> parameter = MapUtil.stringObjectMap("key", "com.ticket.api.service.IWorkTimeService/consumers");
|
||||
Boolean exists = this.mybatisDao().findBySql(Boolean.class, sql, parameter);
|
||||
System.err.println(exists);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TYPE() {
|
||||
String sql = "SELECT TYPE(#{key})";
|
||||
Map<String, Object> parameter = MapUtil.stringObjectMap("key", "com.ticket.api.service.IWorkTimeService/consumers");
|
||||
String type = this.mybatisDao().findBySql(String.class, sql, parameter);
|
||||
System.err.println(type);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TYPE_2() {
|
||||
String sql = "SELECT TYPE('com.ticket.api.service.IWorkTimeService/consumers')";
|
||||
Map<String, Object> parameter = MapUtil.stringObjectMap();
|
||||
String type = this.mybatisDao().findBySql(String.class, sql, parameter);
|
||||
System.err.println(type);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void EXPIREAT() throws Throwable {
|
||||
String sql = "SELECT EXPIREAT(#{key}, #{expire_at})";
|
||||
Map<String, Object> parameter = MapUtil.stringObjectMap("key", "1", "expire_at", Time.now().plusYear(100).toTimestamp());
|
||||
int updateBySql = this.mybatisDao().updateBySql(sql, parameter);
|
||||
System.err.println(updateBySql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void EXPIRE() throws Throwable {
|
||||
String sql = "SELECT EXPIRE(#{key}, #{expire})";
|
||||
Map<String, Object> parameter = MapUtil.stringObjectMap("key", "abcde", "expire", 99999);
|
||||
int updateBySql = this.mybatisDao().updateBySql(sql, parameter);
|
||||
System.err.println(updateBySql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void KEYS() {
|
||||
String sql = "SELECT KEYS(#{key})";
|
||||
Map<String, Object> parameter = MapUtil.stringObjectMap("key", "*IWorkTimeService*");
|
||||
List<String> keys = this.mybatisDao().listBySql(String.class, sql, parameter, new Page());
|
||||
System.err.println(keys);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MOVE() {
|
||||
String sql = "SELECT MOVE(#{key}, #{db})";
|
||||
Map<String, Object> parameter = MapUtil.stringObjectMap("key", "aaaa", "db", 2);
|
||||
int updateBySql = this.mybatisDao().updateBySql(sql, parameter);
|
||||
System.err.println(updateBySql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void PERSIST() {
|
||||
String sql = "SELECT PERSIST(#{key})";
|
||||
Map<String, Object> parameter = MapUtil.stringObjectMap("key", "aaaa");
|
||||
int updateBySql = this.mybatisDao().updateBySql(sql, parameter);
|
||||
System.err.println(updateBySql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void PEXPIRE() throws Throwable {
|
||||
String sql = "SELECT PEXPIRE(#{key}, #{expire})";
|
||||
Map<String, Object> parameter = MapUtil.stringObjectMap("key", "abcde", "expire", 99999);
|
||||
int updateBySql = this.mybatisDao().updateBySql(sql, parameter);
|
||||
System.err.println(updateBySql);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.budo.redis.jdbc.driver.mybatis;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class MybatisListTest {
|
||||
@Test
|
||||
public void _() {}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.budo.redis.jdbc.driver.mybatis;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class MybatisSetTest {
|
||||
@Test
|
||||
public void _() {}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.budo.redis.jdbc.driver.mybatis;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class MybatisSortedSetTest {
|
||||
@Test
|
||||
public void _() {}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.budo.redis.jdbc.driver.mybatis;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class MybatisStringTest {
|
||||
@Test
|
||||
public void _() {}
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
package org.budo.redis.jdbc.driver.statement;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import org.budo.redis.jdbc.driver.BaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class HashTest extends BaseTest {
|
||||
@Test
|
||||
public void HDEL() throws Throwable {
|
||||
String sql = "SELECT HDEL(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "key");
|
||||
preparedStatement.setString(2, "field1");
|
||||
preparedStatement.setString(3, "field2");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HDEL_2() throws Throwable {
|
||||
String field1 = "field_1";
|
||||
String sql = "UPDATE hash.session SET " + field1 + "=NULL WHERE key=?";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "key");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HDEL_3() throws Throwable {
|
||||
String field1 = "field_1";
|
||||
String field2 = "field_2";
|
||||
String sql = "UPDATE hash.session SET " + field1 + "=NULL, " + field2 + "=NULL WHERE key=?";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "key");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HEXISTS() throws Throwable {
|
||||
String sql = "SELECT HEXISTS(?,?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaaa");
|
||||
preparedStatement.setString(2, "bbb");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HGET() throws Throwable {
|
||||
String sql = "SELECT HGET(?,?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "key");
|
||||
preparedStatement.setString(2, "field");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HGET_2() throws Throwable {
|
||||
String field = "field_1";
|
||||
String sql = "SELECT " + field + " FROM hash.session WHERE key=?";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "key");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HGET_3() throws Throwable {
|
||||
String field = "field_1111";
|
||||
String sql = "SELECT " + field + " FROM hash.session WHERE key=key_222";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HGETALL() throws Throwable {
|
||||
String sql = "SELECT HGETALL(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "com.ticket.api.service.IWorkTimeService/consumers");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HINCRBY() throws Throwable {
|
||||
String sql = "SELECT HINCRBY(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "HINCRBY-key-3");
|
||||
preparedStatement.setString(2, "HINCRBY-field-4");
|
||||
preparedStatement.setInt(3, 100); // increment
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HINCRBYFLOAT() throws Throwable {
|
||||
String sql = "SELECT HINCRBYFLOAT(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "key-1");
|
||||
preparedStatement.setString(2, "field-2");
|
||||
preparedStatement.setFloat(3, 1); // increment
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HKEYS() throws Throwable {
|
||||
String sql = "SELECT HKEYS(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaaa");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HLEN() throws Throwable {
|
||||
String sql = "SELECT HLEN(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaaa");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HMGET() throws Throwable {
|
||||
String sql = "SELECT HMGET(?,?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaaa");
|
||||
preparedStatement.setString(2, "bbb");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HMSET() throws Throwable {
|
||||
String sql = "SELECT HMSET(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaaa");
|
||||
preparedStatement.setString(2, "bbb");
|
||||
preparedStatement.setString(3, "ccc");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HSET() throws Throwable {
|
||||
String sql = "SELECT HSET(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "key");
|
||||
preparedStatement.setString(2, "field");
|
||||
preparedStatement.setString(3, "value");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HSETNX() throws Throwable {
|
||||
String sql = "SELECT HSETNX(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "key");
|
||||
preparedStatement.setString(2, "field");
|
||||
preparedStatement.setString(3, "value");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void HVALS() throws Throwable {
|
||||
String sql = "SELECT HVALS(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "key");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
package org.budo.redis.jdbc.driver.statement;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
||||
import org.budo.redis.jdbc.driver.BaseTest;
|
||||
import org.budo.support.lang.util.IoUtil;
|
||||
import org.budo.time.Time;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class KeyTest extends BaseTest {
|
||||
@Test
|
||||
public void KEYS() throws Throwable {
|
||||
String sql = "SELECT KEYS(?)";
|
||||
Connection connection = dataSource.getConnection();
|
||||
PreparedStatement preparedStatement = connection.prepareStatement(sql);
|
||||
|
||||
preparedStatement.setString(1, "*a*");
|
||||
// preparedStatement.setBytes(1, "*ITicketLogTerminalEquipmentService*".getBytes());
|
||||
|
||||
// preparedStatement.setAsciiStream(1, new ByteArrayInputStream("*a*".getBytes()));
|
||||
// preparedStatement.setBinaryStream(1, new ByteArrayInputStream("*a*".getBytes()));
|
||||
// preparedStatement.setCharacterStream(1, new StringReader("*a*"));
|
||||
// preparedStatement.setNCharacterStream(1, new StringReader("*a*"));
|
||||
|
||||
ResultSet resultSet = preparedStatement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
System.err.println("characterStream=" + IoUtil.toString(resultSet.getCharacterStream("keys")));
|
||||
}
|
||||
|
||||
resultSet.close();
|
||||
preparedStatement.close();
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void DEL() throws Throwable {
|
||||
String sql = "SELECT DEL(?,?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
// preparedStatement.setString(1, "aaa");
|
||||
// preparedStatement.setString(2, "bbb");
|
||||
preparedStatement.setBytes(1, "aaa".getBytes());
|
||||
preparedStatement.setBytes(2, "bbb".getBytes());
|
||||
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void EXPIRE() throws Throwable {
|
||||
String sql = "SELECT EXPIRE(?,?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setBytes(1, "aaaaa".getBytes());
|
||||
preparedStatement.setInt(2, 111);
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void EXISTS() throws Throwable {
|
||||
String sql = "SELECT EXISTS(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaaa");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void EXISTS_2() throws Throwable {
|
||||
String sql = "SELECT EXISTS(SELECT key FROM wtf WHERE key=?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaaa");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void EXISTS_3() throws Throwable {
|
||||
String sql = "SELECT EXISTS(SELECT key FROM wtf WHERE key='aaaaa')";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TYPE() throws Throwable {
|
||||
String sql = "SELECT TYPE(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaaa");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void EXPIREAT() throws Throwable {
|
||||
String sql = "SELECT EXPIREAT(?,?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaaa");
|
||||
preparedStatement.setLong(2, System.currentTimeMillis());
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void PEXPIRE() throws Throwable {
|
||||
String sql = "SELECT PEXPIRE(?,?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaaa");
|
||||
preparedStatement.setInt(2, 111);
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void PEXPIREAT() throws Throwable {
|
||||
String sql = "SELECT PEXPIREAT(?,?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaaa");
|
||||
preparedStatement.setLong(2, Time.now().toMilliSeconds());
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void TTL() throws Throwable {
|
||||
String sql = "SELECT TTL(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaaa");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void PTTL() throws Throwable {
|
||||
String sql = "SELECT PTTL(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaaaa");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void RANDOMKEY() throws Throwable {
|
||||
String sql = "SELECT RANDOMKEY()";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void RENAME() throws Throwable {
|
||||
String sql = "SELECT RENAME(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaa");
|
||||
preparedStatement.setString(2, "bbb");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void RENAMENX() throws Throwable {
|
||||
String sql = "SELECT RENAMENX(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "aaa");
|
||||
preparedStatement.setString(2, "bbb");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
package org.budo.redis.jdbc.driver.statement;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import org.budo.redis.jdbc.driver.BaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class ListTest extends BaseTest {
|
||||
@Test
|
||||
public void LINDEX() throws Throwable {
|
||||
String sql = "SELECT LINDEX(?,?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "dddddd");
|
||||
preparedStatement.setInt(2, 1);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
// LINSERT key BEFORE|AFTER pivot value
|
||||
@Test
|
||||
public void LINSERT() throws Throwable {
|
||||
String sql = "SELECT LINSERT(?, ?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "lpush-key");
|
||||
preparedStatement.setString(2, "BEFORE");
|
||||
preparedStatement.setString(3, "pivot");
|
||||
preparedStatement.setString(4, "value");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void LLEN() throws Throwable {
|
||||
String sql = "SELECT LLEN(?,?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ffffgggg");
|
||||
preparedStatement.setString(2, "xxxdddd");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void LPOP() throws Throwable {
|
||||
String sql = "SELECT LPOP(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ffffgggg");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void LPUSH() throws Throwable {
|
||||
String sql = "SELECT LPUSH(?, ?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "lpush-key");
|
||||
preparedStatement.setString(2, "v1");
|
||||
preparedStatement.setString(3, "v2");
|
||||
preparedStatement.setString(4, "v3");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void LPUSHX() throws Throwable {
|
||||
String sql = "SELECT LPUSHX(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "lpushx-key");
|
||||
preparedStatement.setString(2, "v2");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void LRANGE() throws Throwable {
|
||||
String sql = "SELECT LRANGE(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "lrange-key");
|
||||
preparedStatement.setInt(2, 0);
|
||||
preparedStatement.setInt(3, 5);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void LREM() throws Throwable {
|
||||
String sql = "SELECT LREM(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "lrem-key");
|
||||
preparedStatement.setInt(2, 0);
|
||||
preparedStatement.setString(3, "val");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void LSET() throws Throwable {
|
||||
String sql = "SELECT LSET(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "lset-key");
|
||||
preparedStatement.setInt(2, 0);
|
||||
preparedStatement.setString(3, "val");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void LTRIM() throws Throwable {
|
||||
String sql = "SELECT LTRIM(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "LTRIM-key");
|
||||
preparedStatement.setInt(2, 0);
|
||||
preparedStatement.setInt(3, 5);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void RPOP() throws Throwable {
|
||||
String sql = "SELECT RPOP(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "RPOP-key");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void RPOPLPUSH() throws Throwable {
|
||||
String sql = "SELECT RPOPLPUSH(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "RPOPLPUSH-key-1");
|
||||
preparedStatement.setString(2, "RPOPLPUSH-key-2");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void RPUSH() throws Throwable {
|
||||
String sql = "SELECT RPUSH(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "RPUSH-key-1");
|
||||
preparedStatement.setString(2, "RPUSH-key-2");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void RPUSHX() throws Throwable {
|
||||
String sql = "SELECT RPUSHX(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "RPUSHX-key-1");
|
||||
preparedStatement.setString(2, "RPUSHX-key-2");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
package org.budo.redis.jdbc.driver.statement;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import org.budo.redis.jdbc.driver.BaseTest;
|
||||
import org.budo.redis.jdbc.driver.statement.mysql.SELECT_HELP;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author li
|
||||
*/
|
||||
public class MysqlTest extends BaseTest {
|
||||
@Test
|
||||
public void SELECT_AT_AT() throws Throwable {
|
||||
String sql = "SELECT @@dddd";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SELECT_HELP_() throws Throwable {
|
||||
String sql = "SELECT * FROM " + SELECT_HELP.TABLE_NAME;
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SELECT_FROM_INFORMATION_SCHEMA() throws Throwable {
|
||||
String sql = "SELECT * FROM information_schema";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SELECT_FROM_MYSQL() throws Throwable {
|
||||
String sql = "SELECT * FROM mysql";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SET_NAMES() throws Throwable {
|
||||
String sql = "SET names";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SHOW_COLUMNS() throws Throwable {
|
||||
String sql = "SHOW COLUMNS FROM";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SHOW_CREATE_TABLE() throws Throwable {
|
||||
String sql = "SHOW CREATE TABLE";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SHOW_DATABASES() throws Throwable {
|
||||
String sql = "SHOW DATABASES";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SHOW_ENGINES() throws Throwable {
|
||||
String sql = "SHOW ENGINES";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SHOW_FULL_COLUMNS() throws Throwable {
|
||||
String sql = "SHOW FULL COLUMNS FROM";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SHOW_FULL_TABLES() throws Throwable {
|
||||
String sql = "SHOW FULL TABLES";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SHOW_FUNCTION_STATUS() throws Throwable {
|
||||
String sql = "SHOW FUNCTION STATUS";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SHOW_PROCEDURE_STATUS() throws Throwable {
|
||||
String sql = "SHOW PROCEDURE STATUS";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SHOW_STATUS() throws Throwable {
|
||||
String sql = "SHOW STATUS";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SHOW_TABLE_STATUS() throws Throwable {
|
||||
String sql = "SHOW TABLE STATUS";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SHOW_VARIABLES() throws Throwable {
|
||||
String sql = "SHOW VARIABLES";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.budo.redis.jdbc.driver.statement;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import org.budo.redis.jdbc.driver.BaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class ScriptTest extends BaseTest {
|
||||
@Test
|
||||
public void EVAL() throws Throwable {
|
||||
String sql = "SELECT EVAL(\"return redis.call('keys', '*budo*')\")";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void EVAL_2() throws Throwable {
|
||||
String sql = "SELECT EVAL(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "return redis.call('keys', '*')");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package org.budo.redis.jdbc.driver.statement;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import org.budo.redis.jdbc.driver.BaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class ServerTest extends BaseTest {
|
||||
@Test
|
||||
public void CONFIG_GET() throws Throwable {
|
||||
String sql = "SELECT CONFIG_GET('databases')";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,169 @@
|
|||
package org.budo.redis.jdbc.driver.statement;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.budo.redis.jdbc.driver.BaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class SetTest extends BaseTest {
|
||||
@Resource(name = "dbtbl_0") // dbtbl_0 // shardingDataSource
|
||||
DataSource dataSource;
|
||||
|
||||
// @Test
|
||||
public void ZLEXCOUNT() throws Throwable {
|
||||
String sql = "SELECT ZLEXCOUNT(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ZLEXCOUNT-key");
|
||||
preparedStatement.setString(2, "2");
|
||||
preparedStatement.setString(3, "3");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SCARD() throws Throwable {
|
||||
String sql = "SELECT SCARD(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SCARD-key");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SADD() throws Throwable {
|
||||
String sql = "SELECT SADD(?, ?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SADD-key");
|
||||
preparedStatement.setString(2, "SADD-2");
|
||||
preparedStatement.setString(3, "SADD-3");
|
||||
preparedStatement.setString(4, "SADD-4");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SDIFF() throws Throwable {
|
||||
String sql = "SELECT SDIFF(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SDIFF-1");
|
||||
preparedStatement.setString(2, "SDIFF-2");
|
||||
preparedStatement.setString(3, "SDIFF-3");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SDIFFSTORE() throws Throwable {
|
||||
String sql = "SELECT SDIFFSTORE(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SDIFFSTORE-1");
|
||||
preparedStatement.setString(2, "SDIFFSTORE-2");
|
||||
preparedStatement.setString(3, "SDIFFSTORE-3");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SINTER() throws Throwable {
|
||||
String sql = "SELECT SINTER(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SINTER-1");
|
||||
preparedStatement.setString(2, "SINTER-2");
|
||||
preparedStatement.setString(3, "SINTER-3");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SINTERSTORE() throws Throwable {
|
||||
String sql = "SELECT SINTERSTORE(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SINTERSTORE-1");
|
||||
preparedStatement.setString(2, "SINTERSTORE-2");
|
||||
preparedStatement.setString(3, "SINTERSTORE-3");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SISMEMBER() throws Throwable {
|
||||
String sql = "SELECT SISMEMBER(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SISMEMBER-1");
|
||||
preparedStatement.setString(2, "SISMEMBER-2");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SMEMBERS() throws Throwable {
|
||||
String sql = "SELECT SMEMBERS(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SMEMBERS-1");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SMOVE() throws Throwable {
|
||||
String sql = "SELECT SMOVE(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SMOVE-1");
|
||||
preparedStatement.setString(2, "SMOVE-2");
|
||||
preparedStatement.setString(3, "SMOVE-3");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SPOP() throws Throwable {
|
||||
String sql = "SELECT SPOP(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ujujujuj");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SRANDMEMBER() throws Throwable {
|
||||
String sql = "SELECT SRANDMEMBER(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SRANDMEMBER-1");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SRANDMEMBER_2() throws Throwable {
|
||||
String sql = "SELECT SRANDMEMBER(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SRANDMEMBER-1");
|
||||
preparedStatement.setInt(2, 5);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SREM() throws Throwable {
|
||||
String sql = "SELECT SREM(?, ?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SRANDMEMBER-1");
|
||||
preparedStatement.setString(2, "SRANDMEMBER-2");
|
||||
preparedStatement.setString(3, "SRANDMEMBER-3");
|
||||
preparedStatement.setString(4, "SRANDMEMBER-4");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SUNION() throws Throwable {
|
||||
String sql = "SELECT SUNION(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SUNION-1");
|
||||
preparedStatement.setString(2, "SUNION-2");
|
||||
preparedStatement.setString(3, "SUNION-3");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SUNIONSTORE() throws Throwable {
|
||||
String sql = "SELECT SUNIONSTORE(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SUNIONSTORE-1");
|
||||
preparedStatement.setString(2, "SUNIONSTORE-2");
|
||||
preparedStatement.setString(3, "SUNIONSTORE-3");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package org.budo.redis.jdbc.driver.statement;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.budo.redis.jdbc.driver.BaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class SortedSetTest extends BaseTest {
|
||||
@Resource(name = "dbtbl_0") // dbtbl_0 // shardingDataSource
|
||||
DataSource dataSource;
|
||||
|
||||
@Test
|
||||
public void ZADD() throws Throwable {
|
||||
String sql = "SELECT ZADD(?, ?, ?, ?, ?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ZADD-key");
|
||||
preparedStatement.setDouble(2, 22);
|
||||
preparedStatement.setString(3, "value-3");
|
||||
preparedStatement.setDouble(4, 44);
|
||||
preparedStatement.setString(5, "value-5");
|
||||
preparedStatement.setDouble(6, 66);
|
||||
preparedStatement.setString(7, "value-7");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ZCARD() throws Throwable {
|
||||
String sql = "SELECT ZCARD(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ZCARD-key");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ZCOUNT() throws Throwable {
|
||||
String sql = "SELECT ZCOUNT(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ZCOUNT-key");
|
||||
preparedStatement.setDouble(2, 222); // min
|
||||
preparedStatement.setDouble(3, 333); // max
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ZINCRBY() throws Throwable {
|
||||
String sql = "SELECT ZINCRBY(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ZINCRBY-key");
|
||||
preparedStatement.setInt(2, 5);
|
||||
preparedStatement.setString(3, "ZINCRBY-member");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ZRANK() throws Throwable {
|
||||
String sql = "SELECT ZRANK(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ZRANK-key");
|
||||
preparedStatement.setString(2, "ZRANK-value");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ZREM() throws Throwable {
|
||||
String sql = "SELECT ZREM(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ZREM-key");
|
||||
preparedStatement.setString(2, "ZREM-member-2");
|
||||
preparedStatement.setString(3, "ZREM-member-2");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ZREMRANGEBYRANK() throws Throwable {
|
||||
String sql = "SELECT ZREMRANGEBYRANK(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ZREMRANGEBYRANK-key");
|
||||
preparedStatement.setLong(2, 2);
|
||||
preparedStatement.setLong(3, 3);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ZREMRANGEBYSCORE() throws Throwable {
|
||||
String sql = "SELECT ZREMRANGEBYSCORE(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ZREMRANGEBYSCORE-key");
|
||||
preparedStatement.setDouble(2, 2);
|
||||
preparedStatement.setDouble(3, 3);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ZREVRANK() throws Throwable {
|
||||
String sql = "SELECT ZREVRANK(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ZREVRANK-key");
|
||||
preparedStatement.setString(2, "ZREVRANK-value");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ZSCORE() throws Throwable {
|
||||
String sql = "SELECT ZSCORE(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "ZSCORE-key");
|
||||
preparedStatement.setString(2, "ZSCORE-value");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,178 @@
|
|||
package org.budo.redis.jdbc.driver.statement;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import org.budo.redis.jdbc.driver.BaseTest;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lmw
|
||||
*/
|
||||
public class StringTest extends BaseTest {
|
||||
@Test
|
||||
public void MGET() throws Throwable {
|
||||
String sql = "SELECT MGET(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "MGET-1");
|
||||
preparedStatement.setString(2, "MGET-2");
|
||||
preparedStatement.setString(3, "MGET-3");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void GET() throws Throwable {
|
||||
String sql = "SELECT GET(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setBytes(1, "SET-key-1".getBytes());
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SET() throws Throwable {
|
||||
String sql = "SELECT SET(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setBytes(1, "SET-key-1".getBytes());
|
||||
preparedStatement.setBytes(2, "SET-value-2".getBytes());
|
||||
this.executeUpdateAndPrint(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void APPEND() throws Throwable {
|
||||
String sql = "SELECT APPEND(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "APPEND-key");
|
||||
preparedStatement.setString(2, "APPEND-value");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void DECR() throws Throwable {
|
||||
String sql = "SELECT DECR(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "DECR-key");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void DECRBY() throws Throwable {
|
||||
String sql = "SELECT DECRBY(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "DECRBY-key");
|
||||
preparedStatement.setLong(2, 2);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void INCR() throws Throwable {
|
||||
String sql = "SELECT INCR(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "INCR-key");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void INCRBY() throws Throwable {
|
||||
String sql = "SELECT INCRBY(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "INCRBY-key");
|
||||
preparedStatement.setLong(2, 2);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void INCRBYFLOAT() throws Throwable {
|
||||
String sql = "SELECT INCRBYFLOAT(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "INCRBYFLOAT-key");
|
||||
preparedStatement.setDouble(2, 2);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void GETSET() throws Throwable {
|
||||
String sql = "SELECT GETSET(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "GETSET-key");
|
||||
preparedStatement.setString(2, "GETSET-value");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void GETRANGE() throws Throwable {
|
||||
String sql = "SELECT GETRANGE(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "GETSET-key");
|
||||
preparedStatement.setInt(2, 2);
|
||||
preparedStatement.setInt(3, 3);
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MSET() throws Throwable {
|
||||
String sql = "SELECT MSET(?, ?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "MSET-key-1");
|
||||
preparedStatement.setString(2, "MSET-value-2");
|
||||
preparedStatement.setString(3, "MSET-key-3");
|
||||
preparedStatement.setString(4, "MSET-value-4");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void MSETNX() throws Throwable {
|
||||
String sql = "SELECT MSETNX(?, ?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "MSETNX-key-1");
|
||||
preparedStatement.setString(2, "MSETNX-value-2");
|
||||
preparedStatement.setString(3, "MSETNX-key-3");
|
||||
preparedStatement.setString(4, "MSETNX-value-4");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void PSETEX() throws Throwable {
|
||||
String sql = "SELECT PSETEX(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "PSETEX-key-1");
|
||||
preparedStatement.setLong(2, 2);
|
||||
preparedStatement.setString(3, "PSETEX-value-2");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void STRLEN() throws Throwable {
|
||||
String sql = "SELECT STRLEN(?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "STRLEN-key-1");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SETRANGE() throws Throwable {
|
||||
String sql = "SELECT SETRANGE(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SETRANGE-key-1");
|
||||
preparedStatement.setLong(2, 2);
|
||||
preparedStatement.setString(3, "SETRANGE-value-3");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SETNX() throws Throwable {
|
||||
String sql = "SELECT SETNX(?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SETNX-key-1");
|
||||
preparedStatement.setString(2, "SETNX-value-2");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void SETEX() throws Throwable {
|
||||
String sql = "SELECT SETEX(?, ?, ?)";
|
||||
PreparedStatement preparedStatement = this.prepareStatement(sql);
|
||||
preparedStatement.setString(1, "SETEX-key-1");
|
||||
preparedStatement.setInt(2, 2);
|
||||
preparedStatement.setString(3, "SETEX-value-3");
|
||||
this.executeQueryAndPrintResultSet(preparedStatement);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE hibernate-configuration SYSTEM
|
||||
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
|
||||
|
||||
<hibernate-configuration>
|
||||
<session-factory>
|
||||
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
|
||||
<property name="hibernate.connection.url">jdbc:redis://127.0.0.1:6379/0</property>
|
||||
<property name="hibernate.connection.password">12369.</property>
|
||||
</session-factory>
|
||||
</hibernate-configuration>
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
<log4j:configuration>
|
||||
<root>
|
||||
<level value="ALL" />
|
||||
<appender-ref ref="CONSOLE_APPENDER" />
|
||||
</root>
|
||||
|
||||
<appender
|
||||
name="CONSOLE_APPENDER"
|
||||
class="org.apache.log4j.ConsoleAppender">
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param
|
||||
name="ConversionPattern"
|
||||
value="budo-redis-jdbc-driver : %p %d %t %l %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
</log4j:configuration>
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:rdb="http://www.dangdang.com/schema/ddframe/rdb"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd
|
||||
http://www.springframework.org/schema/util
|
||||
http://www.springframework.org/schema/util/spring-util.xsd
|
||||
http://www.dangdang.com/schema/ddframe/rdb
|
||||
http://www.dangdang.com/schema/ddframe/rdb/rdb.xsd">
|
||||
|
||||
<bean
|
||||
id="abstract_ds"
|
||||
abstract="true"
|
||||
class="com.alibaba.druid.pool.DruidDataSource"
|
||||
p:driverClassName="org.budo.redis.jdbc.driver.BudoRedisJdbcDriverOnJedis"
|
||||
p:url="jdbc:redis://127.0.0.1:6379/0"
|
||||
p:password="12369."
|
||||
p:maxActive="100"
|
||||
p:maxWait="100"
|
||||
p:initialSize="1"
|
||||
p:minIdle="1"
|
||||
p:proxyFilters-ref="sessionDruidFilters" />
|
||||
|
||||
<util:list id="sessionDruidFilters">
|
||||
<bean class="com.alibaba.druid.filter.stat.MergeStatFilter" />
|
||||
</util:list>
|
||||
|
||||
<bean
|
||||
id="dbtbl_0"
|
||||
parent="abstract_ds" />
|
||||
</beans>
|
|
@ -0,0 +1 @@
|
|||
# budo-solr-jdbc-driver
|
|
@ -0,0 +1,72 @@
|
|||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.budo</groupId>
|
||||
<artifactId>budo-solr-jdbc-driver</artifactId>
|
||||
<version>0.0.2-sd-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
<budo-snapshot-repository-url>https://repo.rdc.aliyun.com/repository/1726-snapshot-ZLxSbx/</budo-snapshot-repository-url>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>budo-snapshot-repository</id>
|
||||
<url>${budo-snapshot-repository-url}</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.33</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.jsqlparser</groupId>
|
||||
<artifactId>jsqlparser</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.budo</groupId>
|
||||
<artifactId>budo-support</artifactId>
|
||||
<version>0.0.3-bs-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.budo</groupId>
|
||||
<artifactId>budo-jdbc-driver</artifactId>
|
||||
<version>0.0.2-dr-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
Loading…
Reference in New Issue