java uniqueresult_关于query.uniqueResult报错问题

java uniqueresult_关于query.uniqueResult报错问题publicfloatcountmonthmoney(Longblogid){java.text.SimpleDateFormatsf=newjava.text.SimpleDateFormat(“yyyyMM”);Stringtoday=sf.format(newjava.util.Date());StringBuilderstring…publicfloatcountmonthmone…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

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,但是还是报错。

展开

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/187418.html原文链接:https://javaforall.net

(0)
上一篇 2022年9月30日 下午5:00
下一篇 2022年9月30日 下午5:00


相关推荐

  • 3.1 代价函数[通俗易懂]

    3.1 代价函数[通俗易懂]3.1代价函数(costfunction)    代价函数有助于将最可能的线性函数与我们的数据相拟合。在线性回归中,我们有一个这样的数据集,m表示训练集样本数,而我们的假设函数,也就是我们用来进行预测的函数,是图中所示的线性函数形式。    接下来,我们引入一些术语,Ɵ0和Ɵ1,这些Ɵi我们将它称作为模型参数,我们要做的就是如何去选择这两个参数。对于不同的Ɵ0和Ɵ1,我们会得到不同

    2022年4月30日
    50
  • python中random函数的使用方法 详解

    python中random函数的使用方法 详解#random各种使用方法importrandom#随机生成[0.1)的浮点数print("random():",random.random())#随机生成1000-9999之间的整数print("randint(1000,9999):",random.randint(1000,9999))#随机生成0-20之间的偶数print("randrange(0,21,2):"…

    2022年6月14日
    38
  • Java Interface用法

    Java Interface用法Javainterface有多种用法,最常见的就是通过interface传递数据第一种publicinterfaceIData{voidvalue(Stringstr);}publicclassClassA{publicvoidsendData(IDataidata){idata.value(“ThisisClassA’valu

    2022年7月16日
    24
  • 因果图法设计测试用例

    因果图法设计测试用例因果图法设计测试用例 1 nbsp 定义 因果图法是一种利用图解法分析输入的各种组合情况 从而设计测试用例的方法 他适合与检查程序输入条件的各种组合情况 2 nbsp 意义 等价类划分和边界值分析方法都是着重考虑输入条件 但没有考虑输入条件的各种组合 输入条件之间的相互制约关系 这样虽然各种输入条件可能出错的情况已经测试测试到了 但多个输入条件组合起来可能出错的情况却被疏忽了 3 nbsp 认识因果图 如果

    2026年3月17日
    2
  • AI 恋人涉黄被判刑,震惊行业!

    AI 恋人涉黄被判刑,震惊行业!

    2026年3月15日
    3
  • getdate()方法_formatdatetime函数

    getdate()方法_formatdatetime函数今天看博客看到了一个关于字符串处理的方法,突然就想到可以用来格式化数据,相比之前我是用判断然后用字符串拼接的方法,比较繁琐,感觉这样做会更加好些。1.str0.padStart(length,str1),将指定字符串str1按照长度填充到字符串str0的头部2.关于月份month和日day为个位数的处理如下:varnowTime=newDate()varnowMonth=String(nowTime.getMonth()+1).padStart(2,’0′)…

    2025年9月1日
    5

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号