問題描述:利用sql語句從數據庫里面取出數據后,對取出的數據進行數據轉換時,出現了
java.math.BigDecimal cannot be cast to java.lang.Integer錯誤,原因是BigDecimal不能直接轉換為Integer類型
解決方法:
先將取出的數據轉換為BigDecimal類型,再將該類型轉換為Integer類型,參考代碼如下所示:
BigDecimal bigDecimal= (BigDecimal)objects[0];
Integer id=Integer.parseInt(bigDecimal.toString());
原文鏈接:https://blog.csdn.net/y_bccl27/java/article/details/94178765