String与StringBuffer传参的区别(1)

private void getValue(StringBuffer denIszero, StringBuffer denIsNull){

Connection conn = null;

Statement stmt = null;

ResultSet rset = null;

conn = getConnection();

Map<String, StringBuffer> map = new HashMap<String, StringBuffer>();
try
{
stmt = conn.createStatement();

StringBuffer str = new StringBuffer();

str.append("select t.id,t.value from t_sys_parameter t where t.id in ('");
str.append(Constants.DEN_ZERO_DISPLAY);
str.append("' , '");
str.append(Constants.DEN_ZERO_IS_USE);
str.append("' , '");
str.append(Constants.DEN_NUM_NULL_DISPLAY);
str.append("' , '");
str.append(Constants.DEN_NUM_NULL_IS_USE);
str.append("')");

//从数据库中获取ID和VALUE
rset = stmt.executeQuery(str.toString());

//把从数据库中获取的结果集循环放在MAP里,ID字段为键,value字段为值
while(rset.next())
{
map.put(rset.getString("id"), new StringBuffer(rset.getString("value")));
}

//当分母为零时,判断它是否被启用,如果启用了,返回结果为1,否则为0
String zeroValue = map.get(Constants.DEN_ZERO_IS_USE).toString();
//如果返回为0,那么特殊标记为空
if(Constants.DEN_ZERO_IN_USE.equals(zeroValue))
{
denIszero = null;
}

else
{
//如果返回1,特殊标记为从数据库中取得的值
denIszero.append(map.get(Constants.DEN_ZERO_DISPLAY));
}

//当分子为空或分母为空时,判断它是否被启用,如果启用了,返回结果为1,否则为0
String nullValue = map.get(Constants.DEN_NUM_NULL_IS_USE).toString();
//如果返回为0,那么特殊标记为空
if(Constants.DEN_NULL_IN_USE.equals(nullValue))
{
denIsNull = null;
}

else
{
//如果返回1,特殊标记为从数据库中取得的值
denIsNull.append(map.get(Constants.DEN_NUM_NULL_DISPLAY));
}

}
catch (SQLException e)
{
log.exceptionLog("SQLBuilderDAO.getCount()", e);
}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值