Description:
java.lang.ArithmeticException: Rounding necessary
at java.math.BigDecimal.divide(BigDecimal.java:465)
at java.math.BigDecimal.setScale(BigDecimal.java:699)
at java.math.BigDecimal.setScale(BigDecimal.java:735)
at com.mysql.jdbc.ResultSet.getBigDecimalFromString(ResultSet.java:5507)
at com.mysql.jdbc.ResultSet.getNativeBigDecimal(ResultSet.java:4016)
at com.mysql.jdbc.ResultSet.getBigDecimal(ResultSet.java:547)
How to repeat:
It is very difficult to code a test case. Please see suggested fix.
Suggested fix:
Change this:
try {
return new BigDecimal(stringVal).setScale(scale);
} catch (NumberFormatException ex) {
throw new SQLException(Messages.getString(
"ResultSet.Bad_format_for_BigDecimal____166") //$NON-NLS-1$
+stringVal +
Messages.getString("ResultSet.___in_column__167") +
columnIndex + "(" //$NON-NLS-1$
+ this.fields[columnIndex - 1] + ").",
SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
}
into this:
try {
//FIXED: no more ArithmeticExceptions
return new BigDecimal(stringVal).setScale(scale,BigDecimal.ROUND_HALF_UP);
} catch (NumberFormatException ex) {
throw new SQLException(Messages.getString(
"ResultSet.Bad_format_for_BigDecimal____166") //$NON-NLS-1$
+stringVal +
Messages.getString("ResultSet.___in_column__167") +
columnIndex + "(" //$NON-NLS-1$
+ this.fields[columnIndex - 1] + ").",
SQLError.SQL_STATE_ILLEGAL_ARGUMENT);
}
Description: java.lang.ArithmeticException: Rounding necessary at java.math.BigDecimal.divide(BigDecimal.java:465) at java.math.BigDecimal.setScale(BigDecimal.java:699) at java.math.BigDecimal.setScale(BigDecimal.java:735) at com.mysql.jdbc.ResultSet.getBigDecimalFromString(ResultSet.java:5507) at com.mysql.jdbc.ResultSet.getNativeBigDecimal(ResultSet.java:4016) at com.mysql.jdbc.ResultSet.getBigDecimal(ResultSet.java:547) How to repeat: It is very difficult to code a test case. Please see suggested fix. Suggested fix: Change this: try { return new BigDecimal(stringVal).setScale(scale); } catch (NumberFormatException ex) { throw new SQLException(Messages.getString( "ResultSet.Bad_format_for_BigDecimal____166") //$NON-NLS-1$ +stringVal + Messages.getString("ResultSet.___in_column__167") + columnIndex + "(" //$NON-NLS-1$ + this.fields[columnIndex - 1] + ").", SQLError.SQL_STATE_ILLEGAL_ARGUMENT); } into this: try { //FIXED: no more ArithmeticExceptions return new BigDecimal(stringVal).setScale(scale,BigDecimal.ROUND_HALF_UP); } catch (NumberFormatException ex) { throw new SQLException(Messages.getString( "ResultSet.Bad_format_for_BigDecimal____166") //$NON-NLS-1$ +stringVal + Messages.getString("ResultSet.___in_column__167") + columnIndex + "(" //$NON-NLS-1$ + this.fields[columnIndex - 1] + ").", SQLError.SQL_STATE_ILLEGAL_ARGUMENT); }