Chapter 27. The javax.sql PackageThe javax.sql package contains the JDBC 2.0 Standard Extension API. The classes and interfaces in this package provide new functionality, such as connection pooling, that do not fall under the scope of the original JDBC API and can therefore be safely packaged separately. The DataSource interface serves as a factory for Connectionobjects; DataSource objects can be registered with a JNDI server, making it possible to get the name of a database from a name service. PooledConnectionsupports connection pooling, which allows an application to handle multiple database connections in a fairly transparent manner. RowSet extends the ResultSetinterface to a JavaBeans component that can be manipulated at design time and used with non-SQL data sources. Figure 27-1 shows the class hierarchy of the javax.sql package. Figure 27-1. The javax.sql package
Provides information about a pooled connection when an event occurs on the connection. If the event is an error event, ConnectionEvent includes the SQLException that is about to be thrown to the application.
Hierarchy: Object-->java.util.EventObject(Serializable)-->ConnectionEvent Passed To: ConnectionEventListener.{connectionClosed(), connectionErrorOccurred()}
An object that implements ConnectionEventListener registers to receive event notifications from PooledConnection objects. The connectionClosed() method is called when the close() method of the PooledConnection object is called, while the connectionErrorOccurred() method is called immediately before an SQLException is thrown to indicate a fatal error condition (one that renders the connection unusable in the future).
Hierarchy: (ConnectionEventListener(java.util.EventListener)) Passed To: PooledConnection.{addConnectionEventListener(), removeConnectionEventListener()}
A factory for PooledConnection objects. Can be registered with a JNDI service or used standalone (for example, in a servlet).
A factory for java.sql.Connection objects. Can be registered with a JNDI service, so that an application can get the name of a database from a name service.
PooledConnection provides an application-level hook into the JDBC Standard Extension's connection pooling functionality. Call getConnection() to retrieve a standard java.sql.Connection object for database access from the connection pool. Use close() to return this connection to the pool.
Implementations: javax.sql.XAConnection Passed To: ConnectionEvent.ConnectionEvent() Returned By: ConnectionPoolDataSource.getPooledConnection()
RowSet extends the java.sql.ResultSet interface so that RowSet objects are JavaBeans components and can be manipulated by visual programming tools. A RowSet can be implemented on top of any JDBC-compliant ResultSet. The setCommand() method specifies what data the row set should contain (for a database generated set, this might be an SQL statement).
Hierarchy: (RowSet(java.sql.ResultSet)) Passed To: RowSetEvent.RowSetEvent()
Generated when an important event, such as a change in a column's value, occurs within a RowSet.
Hierarchy: Object-->java.util.EventObject(Serializable)-->RowSetEvent Passed To: RowSetListener.{cursorMoved(), rowChanged(), rowSetChanged()}
Implemented by a RowSet object that wishes to support the reader/writer row-loading paradigm. Contains additional methods used by RowSetReader and RowSetWriter.
Passed To: RowSetReader.readData(), RowSetWriter.writeData()
Implemented by an object that wishes to be informed of events generated by a RowSet.
Hierarchy: (RowSetListener(java.util.EventListener)) Passed To: RowSet.{addRowSetListener(), removeRowSetListener()}
Extends java.sql.ResultSetMetaData to support the functionality of RowSet objects.
Hierarchy: (RowSetMetaData(java.sql.ResultSetMetaData)) Passed To: RowSetInternal.setMetaData()
Loads data into a RowSet that implements RowSetInternal. The extensions to ResultSet introduced in JDBC 2.0 insert data.
Writes data from a RowSet that implements RowSetInternal. The data from the RowSet can be written back to a data source (not necessarily a database).
An extended version of PooledConnection that can be used in a distributed transaction environment, using the Java Transaction API (in the javax.transaction package).
Hierarchy: (XAConnection(PooledConnection)) Returned By: XADataSource.getXAConnection()
A factory for XAConnection objects.
Copyright © 2001 O'Reilly & Associates. All rights reserved. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|