RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Prevent Stale DB Connections with the Latest OC4J : Page 3

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.


New OC4J Configurable Parameters

Besides the standard parameters (maximum pool size, minimum pool size, maximum number of attempts, maximum period of time of inactivity, and maximum period of time to wait for a JDBC connection before time out), OC4J 10.1.3 offers various new configurable parameters, such as initial-limit, used-connection-wait-timeout, login-timeout, validate-connection, abandoned-connection-timeout, and validate-connection.

These parameters are self-explanatory, but two play a very important role in ensuring that DB connections never go stale: validate-connection and abandoned-connection-timeout. When set to true, validate-connection first validates the connection before giving it to the session bean. Similarly, abandoned-connection-timeout is explicitly applicable for logical connections. The connection manager monitors the database-execute calls issued by each DB connection and based on the inactive time, reclaims and recycles the connection.

Moving Forward

OC4J 10.1.3's implicit connection caching feature has configuration parameters for using all the latest features that are part of Oracle Real Application Clusters (RAC), a recent addition to the Oracle database. RAC prevents application outages from instance failures by having multiple nodes working in parallel with data backup, and Oracle Net Services provides load balancing for a cluster database. Balancing the application workload can provide better performance and can easily support more users by adding more nodes into the cluster.

If you are experiencing intermittent stale DB connections in your Oracle OC4J app server and an app server upgrade is in your plans, now is the time to do it.

Raghu Donepudi, an independent contractor, currently is a technical manager for a federal government agency. He has a master's degree in Computer Science from Lamar University in Texas. He is a Sun-certified Java developer and the author of many software design techniques.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date