File tree Expand file tree Collapse file tree 1 file changed +21
-7
lines changed
src/main/java/org/sqlite/jdbc3 Expand file tree Collapse file tree 1 file changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -153,14 +153,28 @@ public boolean wasNull() throws SQLException {
153
153
154
154
/** @see java.sql.ResultSet#getBigDecimal(int) */
155
155
public BigDecimal getBigDecimal (int col ) throws SQLException {
156
- final String stringValue = getString (col );
157
- if (stringValue == null ) {
158
- return null ;
156
+ final int columnType = getColumnType (col );
157
+
158
+ if (columnType == Types .INTEGER ) {
159
+ long decimal = getLong (col );
160
+ return BigDecimal .valueOf (decimal );
161
+ } else if (columnType == Types .FLOAT || columnType == Types .DOUBLE ) {
162
+ final double decimal = getDouble (col );
163
+ if (Double .isNaN (decimal )) {
164
+ throw new SQLException ("Bad value for type BigDecimal : Not a Number" );
165
+ } else {
166
+ return BigDecimal .valueOf (decimal );
167
+ }
159
168
} else {
160
- try {
161
- return new BigDecimal (stringValue );
162
- } catch (NumberFormatException e ) {
163
- throw new SQLException ("Bad value for type BigDecimal : " + stringValue );
169
+ final String stringValue = getString (col );
170
+ if (stringValue == null ) {
171
+ return null ;
172
+ } else {
173
+ try {
174
+ return new BigDecimal (stringValue );
175
+ } catch (NumberFormatException e ) {
176
+ throw new SQLException ("Bad value for type BigDecimal : " + stringValue );
177
+ }
164
178
}
165
179
}
166
180
}
You can’t perform that action at this time.
0 commit comments