I have a simple query using JDBC of an Oracle database which is proving slow to retrieve, even though the query itself doesn't seem to be the problem. A profiler reveals that a lot of time is spent in:
Res开发者_Python百科ultSet#getString(String)
methods, some of which are retrieving Oracle NUMBER
columns which are of Java long
precision, or thereabouts. These values may also be null.
I am guessing that getString(String)
is slow when returning a column value that is defined as a number - and thought about using getLong(String)
but of course that returns a primitive that cannot be null.
Is there a better way? Can a JDBC NUMERIC
value be returned as an object without converting it to a String
or incurring any other conversion cost?
Something like this?
long value = resultSet.getLong(colName);
if (resultSet.wasNull()) {
return null;
} else {
return Long.valueOf(value);
}
精彩评论