How to get JDBC NUMERIC column value, which can be NULL, without any conversion cost?

I have a simple query using JDBC Oracle database, which is slowly recovering, although the query itself is not a problem. The profiler shows that a lot of time is spent on:

ResultSet#getString(String) 

some of which retrieve Oracle NUMBER columns that have Java long precision or so. These values ​​can also be zero.

I assume 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 it returns a primitive that cannot be null.

Is there a better way? Can JDBC NUMERIC be returned as an object without converting it to String or without resorting to any other conversion cost?

+4
source share
1 answer

Something like that?

 long value = resultSet.getLong(colName); if (resultSet.wasNull()) { return null; } else { return Long.valueOf(value); } 
+6
source

Source: https://habr.com/ru/post/1310497/


All Articles