Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Prevent Stale DB Connections with the Latest OC4J

Applying the same database connection code for all session beans can lead to stale DB connections in large enterprise Java applications. Oracle Containers for J2EE (OC4J) has a new mechanism to nip this problem in the bud.


advertisement
hen building a large-scale J2EE/Java EE application, developers have a few options for establishing database (DB) connectivity from EJBs, including handling it transparently using a J2EE data source, or encapsulating JDBC details inside a Data Access Object (DAO) or inside a single class from which all session beans retrieve the DB connections. However, when using Oracle Containers for J2EE (OC4J), many enterprise Java developers establish a data-sources configuration through the EJB framework by using session beans with bean-managed persistence.

The problem with this approach, which establishes/retrieves a connection from the connection pool in the ejbCreate() method and releases it in ejbRemove(), is that when developers apply it to large applications with hundreds—or even thousands—of stateless session beans, database connections can get held up and eventually become stale (see Sidebar 1. Retaining a DB Connection Throughout a Stateless Session Bean's Lifecycle). Consequently, when session beans try to process an application's service request using a stale DB connection, the user sees unusual errors. They need to restart the application server to resolve the problem.

Oracle Application Server 10g Release 3 (10.1.3) addresses this challenge with the introduction of DB Connection Manager and OC4J's implicit connection caching mechanism. This article details the features of this mechanism, which enables managed data source configuration, and its benefits to existing J2EE applications. While the discussion details using Oracle Application Server 10g, J2EE/Java EE-compliant app servers can also provide this feature by using the latest OC4J Oracle JDBC libraries.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap