Skip Headers
Oracle® Containers for J2EE JSP Tag Libraries and Utilities Reference
10g Release 3 (10.1.3)
Part No. B14425-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

B Deprecated JavaBeans for Data Access

This chapter summarizes custom Java Bean classes for database access that have been deprecated.

B.1 Data Access JavaBeans

The following custom JavaBeans provided with OC4J for database access are deprecated as of Oracle Application Server 10g Release 3 (10.1.3). The beans are included in the oracle.jsp.dbutil package.

OracleConnectionCacheImpl, which ConnCacheBean extends, is also deprectated.

The following discussion presumes a working knowledge of Oracle JDBC. Consult the Oracle9i JDBC Developer's Guide and Reference as necessary.

To use the data-access JavaBeans, verify that the file ojsputil.jar is installed and in your classpath. This file is provided with the OC4J installation. For XML-related methods and functionality, you will also need the file xsu12.jar (for JDK 1.2.x) or xsu111.jar (for JDK 1.1.x), both of which are provided with Oracle Application Server.

You will also need appropriate JDBC driver classes installed and in your classpath, such as classes12.zip for Oracle Database and JDK 1.2 or higher.

B.1.1 Data-Access JavaBean Descriptions

The following sections describe attributes and methods of the data-access JavaBeans—ConnBean, ConnCacheBean, DBBean, and CursorBean—and concludes with an example that uses a data source:

B.1.1.1 ConnCacheBean for Connection Caching

Use oracle.jsp.dbutil.ConnCacheBean to use the Oracle JDBC connection caching mechanism, using JDBC 2.0 connection pooling, for your database connections. Refer to the Oracle9i JDBC Developer's Guide and Reference for information about connection caching.


Notes:

  • To use data sources or simple connection objects, use ConnBean instead.

  • ConnCacheBean extends OracleConnectionCacheImpl, which extends OracleDataSource (both in Oracle JDBC package oracle.jdbc.pool).


ConnCacheBean has the following properties:

  • user: user ID for database schema

  • password: user password

  • URL: database connection string

  • maxLimit: maximum number of connections allowed by this cache

  • minLimit: minimum number of connections existing for this cache

    If you use fewer than this number, there will also be connections in the idle pool of the cache.

  • stmtCacheSize: cache size for Oracle JDBC statement caching

    Setting stmtCacheSize enables the Oracle JDBC statement caching feature. Refer to the Oracle9i JDBC Developer's Guide and Reference for information about Oracle JDBC statement caching features and limitations.

  • cacheScheme: type of cache

    This is indicated by one of the following int constants.

    • DYNAMIC_SCHEME: New pooled connections can be created above and beyond the maximum limit, but each one is automatically closed and freed as soon as the logical connection instance that it provided is no longer in use.

    • FIXED_WAIT_SCHEME: When the maximum limit is reached, any new connection waits for an existing connection object to be released.

    • FIXED_RETURN_NULL_SCHEME: When the maximum limit is reached, any new connection fails, returning null, until connection objects have been released.

The ConnCacheBean class supports methods defined in the Oracle JDBC OracleConnectionCacheImpl class, including the following getter and setter methods for its properties:

  • void setUser(String)

  • String getUser()

  • void setPassword(String)

  • String getPassword()

  • void setURL(String)

  • String getURL()

  • void setMaxLimit(int)

  • int getMaxLimit()

  • void setMinLimit(int)

  • int getMinLimit()

  • void setStmtCacheSize(int)

  • int getStmtCacheSize()

  • void setCacheScheme(int)

    Specify ConnCacheBean.DYNAMIC_SCHEME, ConnCacheBean.FIXED_WAIT_SCHEME, or ConnCacheBean.FIXED_RETURN_NULL_SCHEME.

  • int getCacheScheme()

    Returns ConnCacheBean.DYNAMIC_SCHEME, ConnCacheBean.FIXED_WAIT_SCHEME, or ConnCacheBean.FIXED_RETURN_NULL_SCHEME.

The ConnCacheBean class also inherits properties and related getter and setter methods from the oracle.jdbc.pool.OracleDataSource class. This provides getter and setter methods for the following properties: databaseName, dataSourceName, description, networkProtocol, portNumber, serverName, and driverType. For information about these properties and their getter and setter methods, see the Oracle9i JDBC Developer's Guide and Reference.


Note:

As with any JavaBean you use in a JSP page, you can set any of the ConnCacheBean properties with a jsp:setProperty action instead of using the setter method directly.

Use the following methods to open and close a connection:

  • Connection getConnection()

    Get a connection from the connection cache using ConnCacheBean property settings.

  • void close()

    Close all connections and any open cursors.

Although the ConnCacheBean class does not support Oracle JDBC update batching and row prefetching directly, you can enable these features by calling the setDefaultExecuteBatch(int) and setDefaultRowPrefetch(int) methods of the Connection object that you retrieve from the getConnection() method. Alternatively, you can use the setExecuteBatch(int) and setRowPrefetch(int) methods of JDBC statement objects that you create from the Connection object. (Update batching is supported only in prepared statements.) Refer to the Oracle9i JDBC Developer's Guide and Reference for information about these features.


Notes:

  • ConnCacheBean has the same functionality as the OracleConnectionCacheImpl class. See the Oracle9i JDBC Developer's Guide and Reference for more information.

  • When you use ConnCacheBean, use normal Connection object functionality to create and execute statement objects (unlike the case with ConnBean).


B.1.1.2 DBBean for Queries Only

Use oracle.jsp.dbutil.DBBean to execute queries only.


Notes:

  • DBBean has its own connection mechanism but does not support data sources. If you require a data source, use ConnBean instead.

  • Use CursorBean for any other DML operations (UPDATE, INSERT, DELETE, or stored procedure calls).


DBBean has the following properties:

  • user: user ID for database schema

  • password: user password

  • URL: database connection string

DBBean provides the following setter and getter methods for these properties:

  • void setUser(String)

  • String getUser()

  • void setPassword(String)

  • String getPassword()

  • void setURL(String)

  • String getURL()


    Note:

    As with any JavaBean you use in a JSP page, you can set any of the DBBean properties with a jsp:setProperty statement instead of using the setter method directly.

Use the following methods to open and close a connection:

  • void connect()

    Establish a database connection using DBBean property settings.

  • void close()

    Close the connection and any open cursors.

Use either of the following methods to execute a query:

  • String getResultAsHTMLTable(String)

    Input a string that contains the SELECT statement. This method returns a string with the HTML commands necessary to output the result set as an HTML table. SQL column names (or aliases) are used for the table column headers.

  • String getResultAsXMLString(String)

    Input a string with the SELECT statement. This method returns the result set as an XML string, using SQL names (or aliases) for the XML tags.