Chapter 9. Advanced JDBC Features

In the previous chapter, we covered the essential features of JDBC, most of which were introduced in the JDBC 1.0 specification, the version of JDBC included in JDK 1.1. In this chapter, we will learn additional JDBC 1.0 options, but we will also cover new features introduced in JDBC 2.0 and 3.0.

First, we will consider the different ways we can connect to a database. We will cover:

  • Different types of JDBC drivers

  • Different ways of supplying the connection information, such as the database URL, username, and password

  • The DataSource class, new in JDBC 3.0, that Sun recommends we use

Next, we will consider some additional ResultSet options that were introduced in JDBC 2.0:

  • Scrollability the ability to navigate the ResultSet backward and forward, as well as moving to specific records

  • Sensitivity the ability to see changes made to the database by others without re-executing the query

  • Updateability the ability to change values in the ResultSet and store those changes in the database

We will also look at another new JDBC 3.0 feature, RowSets. RowSets are an extension of ResultSets that adds a JavaBean interface. We will look in particular at Oracle's implementation of two types of RowSets:

  • Cached RowSet caches a ResultSet so we can use it even if we are not connected to a database. Cached RowSets are serializable, so they can be saved in files and transmitted to remote users. Because they have the full functionality of a ResultSet, they can be browsed and updated. Changes can later be applied to the database by reconnecting.

  • JDBC RowSet provides a thin wrapper around a ResultSet. This is useful principally if we want to take advantage of RowSet as a JavaBean component.

In Chapter 6, we covered Oracle's object-relational features. Here, we will see how to work with those features in JDBC. We examine two approaches:

  • Weakly typed objects use a generic object, Struct (or Oracle's extension, STRUCT), that we can use to hold an Oracle database object.

  • Strongly typed objects use a custom class that implements the SQLData interface (or Oracle's extension, ORAData) to hold Oracle database objects and can be integrated as a first-class object in our Java architecture.



Java Oracle Database Development
Java Oracle Database Development
ISBN: 0130462187
EAN: 2147483647
Year: 2002
Pages: 71

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net