publicfloatcountmonthmoney(Longblogid){java.text.SimpleDateFormatsf=newjava.text.SimpleDateFormat(“yyyyMM”);Stringtoday=sf.format(newjava.util.Date());StringBuilderstring…
public float countmonthmoney(Long blogid) {
java.text.SimpleDateFormat sf = new java.text.SimpleDateFormat(“yyyyMM”);
String today = sf.format(new java.util.Date());
StringBuilder stringBuilder = new StringBuilder(“select sum(d.emolument) from ” + DesignerSelled.REF+ ” as d where d.” + designerSelled.PROP_DESIGNERID+ “=” + blogid + ” and ” + “to_char(d.”+ DesignerSelled.PROP_SELLEDTIME + “,’yyyyMM’)” + “='”+ today + “‘”);
Session session = null;
float result = 0.0f;
try {
session = this.getSession();
Query query = session.createQuery(stringBuilder.toString());
result = Float.parseFloat((query.uniqueResult()==null?””:query.uniqueResult()).toString());
} finally {closeSession(session);}return result;}
那位高手帮忙看看呀,我这样写是没有错的,但是,每当数据库DesignerSelled表中emolument没有值的时候就会报错 result = Float.parseFloat((query.uniqueResult()==null?””:query.uniqueResult()).toString());就是这句出错严重: Servlet.service() for servlet default threw exception
java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:994)
at java.lang.Float.parseFloat(Float.java:422)
at com.ipingou.shopping.model.dao.impl.DesignerSelledDAOImpl.countmonthmoney(DesignerSelledDAOImpl.java:232)
at com.ipingou.shopping.web.action.member.MemberConsoleAction.toListMyPay(MemberConsoleAction.java:734)
我的字段不为空,我已经给它设为0,但是还是报错。
展开
今天的文章java uniqueresult_关于query.uniqueResult报错问题分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/13059.html