In my project, there is a function that gets the query results depending on the column type. In this case, the column type is defined in the Oracle database as: NUMBER(15, 5). But the actual query result is an integer number such as : 2000 But the problem is, that in the code, we convert it to decimal and the result will be changed to: 2000.00000
We use BigDecimal, and we put the scale on the result. Is there a short, correct way to deal with all results from database within the column type of: NUMBER(15, 5) ? When the result is Integer is will be Integer, and when it's a decimal with scale of 5 then the result will be like this. This is the case within our switch case that deals with it:
String cellData;
case Types.DECIMAL:
BigDecimal number = rs.getBigDecimal(i);
if (number != null) {
int scale = rsMetadata.getScale(i);
int precision = rsMetadata.getPrecision(i);
cellData = number.setScale(scale).toPlainString();
Maybe something to do with the precision? Because now we only use the scale.