I'm trying to replace this deprecated method, but the suggested replacement omits the Scale
parameter.
The scale parameter seems critical to my application, but I'm unable to figure out an efficient way to retain the precision value.
In case of ResultSet
object, however, the setScale()
method is a saving grace, but there's no such method in CallableStatement
. Can anyone please suggest an alternative?
As specified in the documentation of CallableStatement.getBigDecimal(int parameterIndex, int scale)
:
Deprecated. use
getBigDecimal(int parameterIndex)
orgetBigDecimal(String parameterName)
Using getBigDecimal(int)
or getBigDecimal(String)
, will return the
[..] the value of the designated JDBC
NUMERIC
parameter as ajava.math.BigDecimal
object with as many digits to the right of the decimal point as the value contains.
If you need to change the scale, then you need to use BigDecimal.setScale(int newScale, RoundingMode roundingMode)
(or one of its siblings). This is what most (if not all) JDBC drivers do anyway inside the deprecated getBigDecimal(int parameterIndex, int scale)
method.