Hi:

In the EJB solution, if one has a bean (either session or entity) that
requires access to the database, one must use DataSource object. I know of
several ways to do this:

1. Declare the DataSource object as a non-static member of the bean. This is
a bad solution, because, if you have 1000 beans in your EJB containers, you
end up with 1000 data sources instances.

2. Declare the DataSource object as STATIC member of the bean. Now you have
only one instance of the DataSource object, but you have to worry about
controlling the concurrent access to it. That by itself can be a bottleneck.
Looking at the ConnectionManager.java source, it seems that the
getConnection() method is declared as a "synchronized".

3. Have a separate class that is following the "singleton" design pattern,
and provides two static methods (getConnection, and closeConnection) that
can be called to get and release a "Connection" object from and to the
database connection pool. This solution has a problem, because a developer
must remember to do the get/close combo in it's bean. No container
involvement!

In summary, it seems to be that EJB provides database connection pooling at
the object level. However, Microsoft solution, Microsoft Transaction Server
(MTS) does it at the container level. That is, they have implemented
solution 3.

Anyway, I would like to know your thoughts. WHAT IS THE MOST EFFICIENT AND
EASIEST WAY TO USE DATABASE CONNECTION IN EJB BEANS?

Thanks and Regards
Ramin Javanbakht

----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".

Reply via email to