我在生产线上遇到异常
int cdStatus = ((Integer)vecColumns.elementAt(1)).intValue();
00000050 CommerceSrvr E com.ibm.commerce.command.ECCommandTarget executeCommand CMN0420E:
The following command exception has occurred during processing: "java.lang.ClassCastException: java.math.BigDecimal incompatible with java.lang.Integer".
java.lang.ClassCastException: java.math.BigDecimal incompatible with java.lang.Integer
at com.ibm.commerce.promotion.facade.server.commands.ValidateUniquePromotionCodesTaskCmdImpl.verifyPromotionCodes(ValidateUniquePromotionCodesTaskCmdImpl.java:137)
at com.ibm.commerce.promotion.facade.server.commands.ValidateUniquePromotionCodesTaskCmdImpl.performExecute(ValidateUniquePromotionCodesTaskCmdImpl.java:84)
这里 veColumn 是一个 Vector,elementAt(1) 是数据库中的一个列,在数据库端的类型为smallInt。我不确定这张图中有多大的小数?
最佳答案
您从数组中提取的元素具有 BigDecimal 类型。您无法将 BigDecimal 转换为 Integer。将转换为 Integer 的转换替换为转换为 BigDecimal 的转换,它应该可以工作。
关于java - 将 Bigdecimal 转换为 Integer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30423221/