DAO and DB connections
843829Mar 4 2004 — edited May 2 2004Hi 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