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();**
}
时间: 2024-11-03 17:00:41