25.8. Summary
In this chapter, you've applied the basic JDBC skills you learned about in the previous chapter in some new ways, extended your detailed knowledge of some of the topics I covered there, and even got into some new ones. The important elements that I introduced in this chapter include:
You can create Java objects directly from JDBC data sources by adding a factory method to a class to extract data from a ResultSet object and build a class object.
The Statement interface provides methods that enable you to limit the field size and number of rows that can be generated in a resultset. You can also set a maximum duration for an SQL query.
A PreparedStatement object encapsulates a parameterized SQL statement and provides methods for you to set values for the parameters. Placeholders for the parameters in the SQL statement are represented by a question mark.
JDBC provides a set of preferred mappings between SQL types and Java types. The methods provided for transferring data between your program and a database also support conversions to other than the preferred types.
The SQL NUMERIC and DECIMAL data types are mapped to the BigDecimal class type that is defined in the java.math package. You can use this class and the BigInteger class for applications that need numerical precision beyond the capabilities of the primitive numeric types.
When exceptions are thrown by JDBC methods, a chain of SQLException objects can be linked together. You can access successive objects in the chain ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access