java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Double

Following the previous blog post, the JVM throws an exception when processing a large amount of table data:
java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Double
Insert picture description here
subconsciously thinks that he has written the wrong unboxing, or I remembered the packaging class incorrectly.
After carefully checking the error message, I found that the data type of the database field is not the same as expected.

For insurance purposes, the data types of the corresponding fields in the following table are verified:

	private static String getType(Object a) {
    
    
        return a.getClass().toString();
    }
System.out.println(getType(listname.get(0).get(key)));
System.out.println(getType(listarea.get(0).get(key)));
System.out.println(getType(list.get(i).get("DEFECT_AREA")));

The result is shown in the figure:
Insert picture description here
With the help of the database query tool DbVis, the table field was also found: I
Insert picture description here
confirmed that I made a mistake in the data type by mistake, and changed the packaging class of Map to BigDecimal to
be continued. . .

Guess you like

Origin blog.csdn.net/Beatingworldline/article/details/113561045