O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using get methods effectively

JDBC provides different types of methods to retrieve data from a result set, such as getInt, getString, and getObject; the getObject method is the generic one, and you can use it for all data types. But, we should always avoid the use of getObject because it gives worse performance than others. When we get data with the use of getObject, the JDBC driver must perform extra processing to determine the type of value being fetched and generate the appropriate mapping. We should always use the specific method for the data type; this provides better performance than using a generic one like getObject.

We can also improve the performance by using a column number instead of a column name; for example, getInt(1), getString(2) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required