当前位置 : 主页 > 编程语言 > java >

ResultSetExtractor

来源:互联网 收集:自由互联 发布时间:2022-08-10
private ResultSetExtractor hKTCloudExtractor; //多态 public HKTCloudUserDaoImpl () { //polymorphellosm hKTCloudExtractor = new HKTCloudSetExtractor (); } public class HKTCloudSetExtractor implements ResultSetExtractor { //get HKTCloudUser


private ResultSetExtractor hKTCloudExtractor;

 

 

//多态
public HKTCloudUserDaoImpl() {
//polymorphellosm
hKTCloudExtractor = new HKTCloudSetExtractor();
}

 

 

public class HKTCloudSetExtractor implements ResultSetExtractor {

//get HKTCloudUser data from db
@Override
public Object extractData(ResultSet rs) throws SQLException,
DataAccessException {
HKTCloudUser hktCloudUser = null;
if (rs.next()) {
hktCloudUser = new HKTCloudUser();
hktCloudUser.setUserId(rs.getString(DBConstants.HKT_CLOUD_USER_ID));
hktCloudUser.setMsisdn(rs.getString(DBConstants.HKT_CLOUD_MSISDN));
hktCloudUser.setCloudName(rs.getString(DBConstants.HKT_CLOUD_CLOUD_NAME));
hktCloudUser.setCloudId(rs.getString(DBConstants.HKT_CLOUD_CLOUD_ID));
hktCloudUser.setStatus(rs.getString(DBConstants.HKT_CLOUD_STATUS));
hktCloudUser.setQuota(rs.getString(DBConstants.HKT_CLOUD_QUOTA));
hktCloudUser.setUserPackage(rs.getString(DBConstants.HKT_CLOUD_PACKAGE));
}

return hktCloudUser;
}

}

 

查询方法内可以调用jdbc query查询

HKTCloudUser hKTCloudUser = null;

Object[] param = null;
param = new Object[] { msisdn };
hKTCloudUser = (HKTCloudUser) jdbcTemplate.query(sql, param, hKTCloudExtractor);

 

第二种:

public Object mapRow(ResultSet rs, int arg1) throws SQLException {

Subscriber subscriber = new Subscriber();
subscriber.setMsisdn(rs.getString(DBConstants.USER_MSISDN));
subscriber.setMsisdn_create_date(rs.getString(DBConstants.USER_CREATE_DATE));
subscriber.setMsisdn_mark_delete_date(rs.getString(DBConstants.USER_MARK_DELETE_DATE) == null ? "": rs.getString(DBConstants.USER_MARK_DELETE_DATE));
subscriber.setSubscribed_type(rs.getString(DBConstants.USER_SUNSCRIBED_TYPE));
subscriber.setEfax_number(rs.getString(DBConstants.EFAX_NUMBER));
subscriber.setEfax_loginId(rs.getString(DBConstants.EFAX_LOGIN_ID));
subscriber.setEfax_password(rs.getString(DBConstants.EFAX_PASSWORD));
subscriber.setEfax_create_date(rs.getString(DBConstants.EFAX_CREATE_DATE));
subscriber.setCommond(rs.getString(DBConstants.EFAX_ID_COMMON)== null? "": rs.getString(DBConstants.EFAX_ID_COMMON));

return subscriber;
}

 

上一篇:getListView()用法
下一篇:没有了
网友评论