The data access beans are Java classes written to the JavaBeans specification. Data access beans provide a rich set of features and enhanced function with respect to the java.sql package, while hiding much of the complexity associated with accessing relational databases.
You can use the data access beans in JavaBeans-compliant tools, such as the IBM product VisualAge for Java. Because the data access beans are also Java classes, you can use them like ordinary classes as well.
Beginning with WebSphere Application Server Version 3.x, the data access beans have used the JDBC 2.0 Optional Package APIs to take advantage of DataSource objects and connection pooling.
The data access beans (in the package com.ibm.db) offer the following capabilities:
Feature | Details |
---|---|
Caching of query results | SQL query results can be retrieved all at once and placed in a cache.
Programs using the result set can move forward and backward through the cache or jump directly to
any result row in the cache.
In contrast, java.sql classes retrieve rows from the database one at a time, in the forward direction only. Each newly retrieved row overlays the previously retrieved row unless additional code is included to expand functionality. For large result sets, the data access beans provide ways to retrieve and manage packets, subsets of the complete result set. |
Updates through result cache | Programs can use standard Java statements (rather than SQL statements) to change, add, or delete rows in the result cache. Changes to the cache can be propagated to the underlying relational table. | Query parameter support | The base SQL query is defined as a Java String, with parameters replacing some of the actual values. When the query is run, the data access beans provide a way to replace the parameters with values made available at run time. Default mappings for common datatypes are provided, but you can specify whatever your Java program and database require. |
Metadata support |
A StatementMetaData object contains the base SQL query.
Information about the query (metadata)
enables the object to pass parameters into the query as
Java datatypes.
Metadata in the object maps Java datatypes to SQL datatypes (as well as the reverse). When the query is run, the Java-datatyped parameters are automatically converted to SQL datatypes as specified in the metadata mapping. When results are returned, the metadata object automatically converts SQL datatypes back into the Java datatypes specified in the metadata mapping. |