Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

DAO and DB connections

843829Mar 4 2004 — edited May 2 2004
Hi all,
I have a Stateful and a Stateless Session Beans
that use two DAOs to retrieve DB data.

My beans in order:

- retrieve DAO Factory
- ask DAO Factory to create a new DAO
- use the DAO

inside DAO constructor method I put the code
to get the DB Connection.
More exactly DAO constructor method calls a static DAOFactory method, createConnection(): createConnection() uses JNDI to lookup the DataSource and the calls
DataSource.getConnection().

My question is:
I must explicitly close the DB Connection created
(for example writing a destroyConnection() static method
inside DAOFactory ?) or the connection is closed
by the Application Server when my Session Beans
are removed (or passivated) ?

In first case, destroyConnection() method to code,
this method simply must call Connection.close() ?

Many thanks in advance,
Moreno
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 30 2004
Added on Mar 4 2004
4 comments
252 views