kuoren 2015-08-06 1030浏览量
public Boolean bindCard(final BindCardProfile bindCardProfile) throws DataAccessException {
if (bindCardProfile == null) {
return false;
}
String dbReturn = jdbcTemplate.execute(new CallableStatementCreator() {
@Override
public CallableStatement createCallableStatement(Connection con) throws SQLException, DataAccessException {
// TODO Auto-generated method stub
String stroedProc = "CALL sp_bind_card(?, ?, ?, ?, ?, ?, ?)";
CallableStatement callableStatement = con.prepareCall(stroedProc);
callableStatement.setString("p_cellphone", bindCardProfile.getCellphone());
callableStatement.setString("p_name", bindCardProfile.getName());
callableStatement.setString("p_id_card", bindCardProfile.getIdCard());
callableStatement.setString("p_bank_card_no", bindCardProfile.getBankCardNo());
callableStatement.setString("p_channel_name", bindCardProfile.getChannelName());
callableStatement.setString("p_bank_abbr", bindCardProfile.getBankAbbr());
callableStatement.registerOutParameter("p_returnVal", Types.NVARCHAR);
return callableStatement;
}
}, new CallableStatementCallback<String>() {
public String doInCallableStatement(CallableStatement callableStatement)
throws SQLException, DataAccessException {
callableStatement.execute();
return callableStatement.getString("p_returnVal");
}
});
return dbReturn.equals("success");
}
1 在类中使用Spring管理对象时,同时又用Spring对象实例话另一个对象时,注意其位置,如下面的代码,这样定义时会Error,会出现空的指针,具体可能在初始化对象时,和Spring的先后顺序有关
//@Repository
public class CacheKeyManager {
@Resource(name="stringRedisTemplate")
private RedisTemplate<String, String> redisTemplate;
**RedisSerializer<String> stringSerializer=redisTemplate.getStringSerializer();**
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
集结各类场景实战经验,助你开发运维畅行无忧