小程序原生组件—提升你的小程序体验
570
2022-10-24
ResultSetExtractor
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; }
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~