This exception is coming in very strange way.
I am reading a variable's value from a stored procedure whose type is DECIMAL(15,4). And at java end I was type casting this value to BigDecimal, and it was working perfectly fine. Now I started getting this exception :java.lang.ClassCastException: java.lang.Double incompatible with java.math.BigDecimal and to resolve this I am casting this variable type to Double and then casting it back to BigDecimal using
New :
Double myVarDb= //reading some variable's value with type-> DECIMAL(15,4) from Db end
BigDecimal myVar = (BigDecimal)BigDecimal.valueOf(myVarDb);
Old :
BigDecimal myVar= //reading some variable's value with type-> DECIMAL(15,4)
If in case anyone has faced this issue or has any idea why it might come, please guide.
UPDATE : I checked both drivers and below are the versions :
Old : DriverVersion: 3.6.60
NEW : DriverVersion: 3.64.106
The instances which I am getting created after reading the values are of type:
Old : BigDecimal
NEW : Double
So now the problem is clear that why are we getting this exception because we are getting Double object now as default object.
So can anyone throw some light on why these different types of instances are getting created? Is this because of different versions of JDBC driver?