I have a database (MySQL 5.6 if it matters) in which I would like to store numeric values that will usually, but not always, be integers. Right now I have a DECIMAL(10, 3)
column which seems to be working well. What I'm looking for is a method I know doesn't exist in native JDBC, but would be something like:
public Number ResultSet.getNumber()
which would return me a Long
(or maybe even Integer
) if the underlying SQL value is actually an integer, and a Double
otherwise. Is there some way to get an equivalent result from an SQL DECIMAL column in JDBC?