`

java.lang.NumberFormatException: For input string

    博客分类:
  • Java
阅读更多

 

严重: java.lang.NumberFormatException: For input string: "companyCode"

 

在 object数组的时候,要注意好类型的转换.

 

------java.lang.NumberFormatException: For input string 解决方法--------------------------------------------------------
字符分割异常 转化字符或输入字符问题 

 

public List<?> findAgencyArSumDetail(
		SettlementAgencyARDetailResult headInfoArResult) {
		String sql = "SELECT CNTR_SIZE||CNTR_TYPE AS containerSizes,"
				+ " COMPANY_CDE AS companyCode,"
				+ " FULL_EMPTY_IND AS fullEmptyIndicator,"
				+ " EXP_IMP_IND AS expImportIndicator,"
				+ " SOC_IND AS socIndicator,"
				+ " COUNT(*) AS containeraCount,"
				+ " SUM(FEE_AMT) AS toTalNum,"
				+ " FEE_PRICE AS feePrice"
				+ " FROM CBS_SET_DOC_AG_CNTR "
				+ " WHERE SVVD_ID=:svvdId"
				+ " AND PORT_CDE=:portCode"
				+ " AND COMPANY_CDE=:companyCode"
				+ " AND SO_COMPANY_CDE=:SOCompanyCode"
				+ " AND FEE_TYPE=:feeType"
				+ " AND ACT_FLAG=:actualFlag"
				+ " GROUP BY(CNTR_SIZE||CNTR_TYPE,FULL_EMPTY_IND,SOC_IND,EXP_IMP_IND,FEE_PRICE,COMPANY_CDE)";
		SQLQuery querys = (SQLQuery) cbsModuleRepository.getSessionFactory()
		.getCurrentSession().createSQLQuery(sql.toString());
	 
		querys.setParameter(SettlementContant.SVVD_ID,
				headInfoArResult.getSvvdId());
		querys.setParameter(SettlementContant.PORT_CODE,
				headInfoArResult.getPortCode());
		querys.setParameter(SettlementContant.COMPANY_CODE,
				headInfoArResult.getCompanyCode());
		querys.setParameter(SettlementContant.SO_COMPANY_CODE,
				headInfoArResult.getShipownerCompanyCode());
		querys.setParameter(SettlementContant.FEE_TYPE,
				headInfoArResult.getChargeCode());
		querys.setParameter(SettlementContant.ACTUAL_FLAG,
				SettlementContant.ACTUAL_FLAG_Y);
		List<Object[]> list = querys.list();
		SettlementAgencySumDetailResult agencySumDetailResult = null;
		List<SettlementAgencySumDetailResult> queryList = new ArrayList<SettlementAgencySumDetailResult>();
		for (Object[] object : list) {
			agencySumDetailResult = new SettlementAgencySumDetailResult();
			agencySumDetailResult.setContainerSizes((String) object[0]);
			agencySumDetailResult.setCompanyCode((String) object[1]);
			agencySumDetailResult.setFullEmptyIndicator((String) object[2]);
			agencySumDetailResult.setExpImportIndicator((String) object[3]);
			agencySumDetailResult.setSocIndicator((String) object[4]);
			agencySumDetailResult.setContaineraCount((BigDecimal) object[5]);
			agencySumDetailResult.setToTalNum((BigDecimal) object[6]);
			agencySumDetailResult.setFeePrice((BigDecimal) object[7]);
			queryList.add(agencySumDetailResult);
		}
		return queryList;
	}

 注意循环遍历放到 List中..

 

这里还有关于HQL中在字符串的拼接问题.

 

      第一种:
+ " commBl.billBasicUuid= " + docHead.getBusinessReferenceUuid()
+ " AND commBl.companyCode = '" +docHead.getCompanyCode()+"'"
+ " AND commBl.commissionMode '" +arItem.getChargeCodeGroup()+"'"
+ " AND commBl.commissionType '" +arItem.getChargeCode()+"'"

 

hql.append(" WHERE commBl.billBasicUuid=:businessReferenceUuid");
		hql.append(" AND commBl.companyCode =:companyCode");
		hql.append(" AND commBl.commissionMode=:chargeCodeGroup");
		hql.append(" AND commBl.commissionType=:chargeCode");
	第二种:
Query query = cbsModuleRepository.getSessionFactory()
				.getCurrentSession().createQuery(hql.toString());
		query.setParameter(SettlementContant.BUSINESS_REFERENCE_UUID,
				settlementHead.getBusinessReferenceUuid());
		query.setParameter(SettlementContant.COMPANY_CODE,
				settlementHead.getCompanyCode());
		query.setParameter(SettlementContant.CHARGE_CODE_GROUP,
				settlementAR.getChargeCodeGroup());
		query.setParameter(SettlementContant.CHARGE_CODE,
				settlementAR.getChargeCode());

 

 

跟上边的可以比较一下,这里例举2中拼接的例子.

 

分享到:
评论
1 楼 灵力不足 2012-06-10  
Struts Problem Report

Struts has detected an unhandled exception:




Messages:

•For input string: ""



File:

java/lang/NumberFormatException.java



Line number:

48



--------------------------------------------------------------------------------

Stacktraces

java.lang.NumberFormatException: For input string: ""
    java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    java.lang.Integer.parseInt(Integer.java:470)
    java.lang.Integer.valueOf(Integer.java:554)
    com.webExam.action.QuestionAction.getExamBean(QuestionAction.java:47)
    com.webExam.action.QuestionAction.create(QuestionAction.java:83)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    java.lang.reflect.Method.invoke(Method.java:597)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
    com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
    com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
    org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:94)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:267)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:142)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:166)
    com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:190)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187)
    com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
    org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:52)
    org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:485)
    org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91)
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    java.lang.Thread.run(Thread.java:619)
    

--------------------------------------------------------------------------------

You are seeing this page because development mode is enabled. Development mode, or devMode, enables extra debugging behaviors and reports to assist developers. To disable this mode, set:
   struts.devMode=false
in your WEB-INF/classes/struts.properties file.


我的报错是这样的,那是什么问题呢,也是数据库吗

相关推荐

    java.lang.NumberFormatException For inputstring 4294967295处理方法

    "For input string: '4294967295'" 这个错误消息表明在尝试转换的字符串 `'4294967295'` 过程中出现了问题。让我们深入探讨这个异常的原因和解决方法。 首先,我们需要理解 `4294967295` 是一个32位无符号整数的...

    JAVA.2核心技术.卷II.高级特性7th.part08.rar

    JAVA.2核心技术.卷II.高级特性7th.part08.rar

    java-bbs项目,ssh

    【Java-BBS项目与SSH框架详解】 在Java领域,SSH(Struts2 + Spring + Hibernate)框架是一个经典的MVC(Model-View-Controller)架构,常用于开发企业级Web应用程序,如论坛系统。本项目“java-bbs”就是基于SSH...

    单片机点阵毕业设计

    点阵的毕业设计。。本文介绍一种基于PIC16F877A[5]单片机控制系统,设计了16×48小型的LED点阵屏。此设计采用动态扫描方式,通过单片机控制3-8译码器74LS138和数据移位寄存器74HC595来驱动显示屏的显示,此方案实用...

    JAVA抛出异常的三种形式详解

    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) at java.lang.Integer.parseInt(Integer.java:580) at java.lang.Integer.parseInt(Integer.java:615) at i ``` 在上面的...

    struts2 的异常收集

    java.lang.NumberFormatException: For input string: "" at java.lang.Integer.parseInt(Integer.java:580) ``` 从上述异常信息可以看出,在执行`Integer.parseInt()`方法时发生了异常,原因是传入了一个空字符串...

    Spring及Mybatis整合占位符解析失败问题解决

    nested exception is java.lang.NumberFormatException: For input string: "${maxActive}"。这个问题是由于占位符${maxActive}未被正确解析引起的。 问题分析: 在Spring框架中,@PropertySource注解可以用来...

    Java实验六 - 实验报告.docx

    Java中的异常是通过类来表示的,这些类都是从`java.lang.Throwable`类派生的。异常分为两种类型:`Error`和`Exception`。`Error`通常代表系统级别的问题,而`Exception`是程序员可以捕获并处理的错误。 ### 2. 异常...

    jsp探针 ver0.1

    Class.forName("org.apache.commons.lang.SystemUtils"); supportCommonLang = true; } catch (ClassNotFoundException ex) { } try { Class.forName("org.apache.regexp.RE"); supportJakartaRegExp = true; } ...

    java练习题库

    - 要把`int`类型转化为`String`类型,可以直接使用`String.valueOf(int)`方法或利用字符串拼接的方式。 - 要把`String`类型转化为`int`类型,需要调用`Integer`类的`parseInt`方法。 #### 三、内部类 **7. 内部类...

    数字格式验证

    `ThtDigit.java`可能包含实现上述功能的代码片段,可能通过正则表达式、自定义函数或者使用现成的库(如Apache Commons Lang的`NumberUtils`)来完成。正则表达式是数字验证的常用工具,可以灵活匹配各种数字格式,...

Global site tag (gtag.js) - Google Analytics