Use the appropriate getXXX and setXXX methods for the type
Use the appropriate getXXX and setXXX methods for the type
JDBC is permissive. It lets you use java.sql.ResultSet.getFloat to retrieve an int, java.sql.ResultSet.getObject to retrieve any type, and so on. (java.sql.ResultSet and java.sql.CallableStatement provide getXXX methods, and java .sql.PreparedStatement and java.sql.CallableStatement provide setXXX methods.) This permissiveness is convenient but expensive in terms of performance.
For performance reasons, use the recommended getXXX method when retrieving values, and use the recommended setXXX method when setting values for parameters.
Table 2 shows the recommended getXXX methods for given java.sql (JDBC) types, and their corresponding SQL types.
Table 2. Mapping of java.sql.Types to SQL Types
Previous Page
Next Page
Table of Contents
Index