本文整理汇总了Java中org.springframework.jdbc.core.RowCallbackHandler类的典型用法代码示例。如果您正苦于以下问题:Java RowCallbackHandler类的具体用法?Java RowCallbackHandler怎么用?Java RowCallbackHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RowCallbackHandler类属于org.springframework.jdbc.core包,在下文中一共展示了RowCallbackHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDomainDetails
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
@Override
public DomainEntity getDomainDetails(String domainId) {
DomainEntity domainEntity = new DomainEntity();
jdbcTemplate.query(SqlDefine.sys_rdbms_084, new RowCallbackHandler() {
@Override
public void processRow(ResultSet resultSet) throws SQLException {
domainEntity.setDomain_id(domainId);
domainEntity.setDomain_desc(resultSet.getString("domain_desc"));
domainEntity.setDomain_status_desc(resultSet.getString("domain_status_desc"));
domainEntity.setMaintance_date(resultSet.getString("maintance_date"));
domainEntity.setCreate_user_id(resultSet.getString("create_user_id"));
domainEntity.setDomain_modify_user(resultSet.getString("domain_modify_user"));
domainEntity.setDomain_modify_date(resultSet.getString("domain_modify_date"));
}
}, domainId);
return domainEntity;
}
示例2: getInformationForUsers
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
@Override
public Map<String, UserBean> getInformationForUsers(final Collection<String> userIds)
{
String sql = config.getUserInfo();
if( Check.isEmpty(sql) )
{
return null;
}
final Map<String, UserBean> users = new HashMap<String, UserBean>();
handleIn(sql, userIds, new RowCallbackHandler()
{
@Override
public void processRow(ResultSet set) throws SQLException
{
String id = set.getString(1);
String username = set.getString(2);
String fname = set.getString(3);
String lname = set.getString(4);
String email = set.getString(5);
DefaultUserBean user = new DefaultUserBean(id, username, fname, lname, email);
users.put(id, user);
}
});
return users;
}
示例3: getRolesForUser
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
@Override
public Pair<ChainResult, Collection<RoleBean>> getRolesForUser(final String userID)
{
String sql = config.getUserRoles();
if( Check.isEmpty(sql) )
{
return null;
}
final Collection<RoleBean> roles = new ArrayList<RoleBean>();
executeSql(sql, getParamValues(sql, userID), new RowCallbackHandler()
{
@Override
public void processRow(ResultSet set) throws SQLException
{
String id = set.getString(1);
String name = set.getString(2);
roles.add(new DefaultRoleBean(id, name));
}
});
return new Pair<ChainResult, Collection<RoleBean>>(ChainResult.CONTINUE, roles);
}
示例4: searchRoles
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
@Override
public Collection<RoleBean> searchRoles(final String query)
{
String sql = config.getSearchRoles();
if( Check.isEmpty(sql) )
{
return null;
}
final Collection<RoleBean> roles = new ArrayList<RoleBean>();
executeSql(sql, getParamValues(sql, query.replace('*', '%')), new RowCallbackHandler()
{
@Override
public void processRow(ResultSet set) throws SQLException
{
String id = set.getString(1);
String name = set.getString(2);
roles.add(new DefaultRoleBean(id, name));
}
});
return roles;
}
示例5: getInformationForRoles
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
@Override
public Map<String, RoleBean> getInformationForRoles(final Collection<String> roleIds)
{
String sql = config.getRoleInfo();
if( Check.isEmpty(sql) )
{
return null;
}
final Map<String, RoleBean> roles = Maps.newHashMapWithExpectedSize(roleIds.size());
handleIn(sql, roleIds, new RowCallbackHandler()
{
@Override
public void processRow(ResultSet set) throws SQLException
{
String id = set.getString(1);
String name = set.getString(2);
roles.put(id, new DefaultRoleBean(id, name));
}
});
return roles;
}
示例6: authenticate
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
private UserInfo authenticate(String username)
{
String sql = config.getAuthenticate();
final UserInfo user = new UserInfo();
executeSql(sql, getParamValues(sql, username), new RowCallbackHandler()
{
@Override
public void processRow(ResultSet set) throws SQLException
{
boolean suspended = set.getInt(3) > 0;
if( suspended )
{
throw new DisabledException("User suspended");
}
String id = set.getString(1);
String password = set.getString(2);
user.setId(id);
user.setPassword(password);
}
});
return user;
}
示例7: getGroupInfo
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
private Map<String, GroupBean> getGroupInfo(Collection<String> ids)
{
final Map<String, GroupBean> groupMap = new HashMap<String, GroupBean>();
String sql = config.getGroupInfo();
if( Check.isEmpty(sql) || Check.isEmpty(ids) )
{
return groupMap;
}
handleIn(sql, ids, new RowCallbackHandler()
{
@Override
public void processRow(ResultSet set) throws SQLException
{
String id = set.getString(1);
String name = set.getString(2);
GroupBean group = new DefaultGroupBean(id, name);
groupMap.put(id, group);
}
});
return groupMap;
}
示例8: loadBeanDefinitions
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
/**
* Load bean definitions from the database via the given SQL string.
* @param sql SQL query to use for loading bean definitions.
* The first three columns must be bean name, property name and value.
* Any join and any other columns are permitted: e.g.
* {@code SELECT BEAN_NAME, PROPERTY, VALUE FROM CONFIG WHERE CONFIG.APP_ID = 1}
* It's also possible to perform a join. Column names are not significant --
* only the ordering of these first three columns.
*/
public void loadBeanDefinitions(String sql) {
Assert.notNull(this.jdbcTemplate, "Not fully configured - specify DataSource or JdbcTemplate");
final Properties props = new Properties();
this.jdbcTemplate.query(sql, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
String beanName = rs.getString(1);
String property = rs.getString(2);
String value = rs.getString(3);
// Make a properties entry by combining bean name and property.
props.setProperty(beanName + "." + property, value);
}
});
this.propReader.registerBeanDefinitions(props);
}
示例9: getJobList
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
@Override
public List<GroupTaskEntity> getJobList(String groupId) {
List<GroupTaskEntity> list = new ArrayList<>();
jdbcTemplate.query(batchSqlText.getSql("sys_rdbms_133"), new RowCallbackHandler() {
@Override
public void processRow(ResultSet resultSet) throws SQLException {
GroupTaskEntity one = new GroupTaskEntity();
one.setCodeNumber(resultSet.getString("code_number"));
one.setDomainId(resultSet.getString("domain_id"));
one.setGroupId(resultSet.getString("group_id"));
one.setJobKey(resultSet.getString("job_key"));
one.setPosTop(resultSet.getInt("pos_top"));
one.setTaskId(resultSet.getString("task_id"));
one.setTaskType(resultSet.getString("task_type"));
one.setTaskTypeDesc(resultSet.getString("task_type_desc"));
one.setTaskDesc(resultSet.getString("task_type_desc"));
one.setPosLeft(resultSet.getInt("pos_left"));
list.add(one);
}
}, groupId);
logger.debug("group id is:{},result is:{}", groupId, list);
return list;
}
示例10: testQueryWithRowCallbackHandlerNoParameters
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
@Test
public void testQueryWithRowCallbackHandlerNoParameters() throws SQLException {
given(resultSet.next()).willReturn(true, false);
given(resultSet.getInt("id")).willReturn(1);
given(resultSet.getString("forename")).willReturn("rod");
final List<Customer> customers = new LinkedList<Customer>();
namedParameterTemplate.query(SELECT_NO_PARAMETERS, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
Customer cust = new Customer();
cust.setId(rs.getInt(COLUMN_NAMES[0]));
cust.setForename(rs.getString(COLUMN_NAMES[1]));
customers.add(cust);
}
});
assertEquals(1, customers.size());
assertTrue("Customer id was assigned correctly", customers.get(0).getId() == 1);
assertTrue("Customer forename was assigned correctly", customers.get(0).getForename().equals("rod"));
verify(connection).prepareStatement(SELECT_NO_PARAMETERS);
verify(preparedStatement).close();
verify(connection).close();
}
示例11: findOne
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
@Override
public RegressionModel findOne(String id) {
final List<RegressionModel> models = new ArrayList<>();
jdbcTemplate.query(SELECT_MODEL.replaceFirst("@", id), new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
RegressionModel m = new RegressionModel();
try {
m.deserializeClassifierFromJson(rs.getString(1));
//m.setLongId(rs.getLong(2));
m.setStringId(rs.getString(2));
m.setGeneratedOn(rs.getDate(3).getTime());
models.add(m);
} catch (IOException e) {
throw new SQLException("Unable to deserialze model from string", e);
}
}
});
return models.isEmpty() ? null : models.get(0);
}
示例12: findUserByUserName
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
@Override
public UserInfo findUserByUserName(String userName) {
// TODO Auto-generated method stub
String sql = "select * from user_info where user_name = ?";
final UserInfo user = new UserInfo();
jdbcTemplate.query(sql, new Object[]{userName}, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
// TODO Auto-generated method stub
if (rs.next()) {
user.setUserId(rs.getLong("user_id"));
user.setUserName(rs.getString("user_name"));
}
}
});
if (user.getUserId() == 0) {
return null;
}
return user;
}
示例13: queryOrderItems
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
@Override
public List<OrderItem> queryOrderItems() {
// TODO Auto-generated method stub
String sql = "SELECT * FROM ORDER_ITEM";
final List<OrderItem> list = new ArrayList<OrderItem>();
jdbcTemplate.query(sql, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
// TODO Auto-generated method stub
OrderItem item = new OrderItem();
item.setItemId(rs.getLong("ITEM_ID"));
item.setGroupId(rs.getLong("GROUP_ID"));
item.setStatus(rs.getInt("STATUS"));
item.setItemCode(rs.getString("ITEM_CODE"));
item.setItemName(rs.getString("ITEM_NAME"));
item.setItemPrice(rs.getFloat("ITEM_PRICE"));
item.setCreateDate(rs.getTimestamp("CREATE_DATE"));
item.setItemPicurl(rs.getString("ITEM_PICURL"));
item.setItemDetails(rs.getString("ITEM_DETAILS"));
list.add(item);
}
});
return list;
}
示例14: selectFoods
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
@Override
public List<FoodInfo> selectFoods() {
String sql = "select food_id, food_name, food_price from food_info";
final List<FoodInfo> list = new ArrayList<FoodInfo>();
jdbcTemplate.query(sql, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
FoodInfo info = new FoodInfo();
info.setFoodId(rs.getLong("food_id"));
info.setFoodName(rs.getString("food_name"));
info.setFoodPrice(rs.getFloat("food_price"));
list.add(info);
}
});
return list;
}
示例15: getOrganisationUnitDataSetAssocationMap
import org.springframework.jdbc.core.RowCallbackHandler; //导入依赖的package包/类
@Override
public Map<String, Set<String>> getOrganisationUnitDataSetAssocationMap()
{
final String sql = "select ds.uid as ds_uid, ou.uid as ou_uid from datasetsource d " +
"left join organisationunit ou on ou.organisationunitid=d.sourceid " +
"left join dataset ds on ds.datasetid=d.datasetid";
final SetMap<String, String> map = new SetMap<>();
jdbcTemplate.query( sql, new RowCallbackHandler()
{
@Override
public void processRow( ResultSet rs ) throws SQLException
{
String dataSetId = rs.getString( "ds_uid" );
String organisationUnitId = rs.getString( "ou_uid" );
map.putValue( organisationUnitId, dataSetId );
}
} );
return map;
}