wood burning stoves
The moose likes JDBC and Relational Databases and the fly likes EJB connection pools vs. Individual Oracle logins Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "EJB connection pools vs. Individual Oracle logins" Watch "EJB connection pools vs. Individual Oracle logins" New topic

EJB connection pools vs. Individual Oracle logins

Dave Segal

Joined: Aug 13, 2002
Posts: 20
Can anybody give me advice on using individual Oracle logins, rather then pooled connections with a common/shared account with EJB's? We are using WebLogic, and I have successfully set up and used connection pools. But, using this technique, Oracle connections are defined statically, and eveyone using a particular connection pool connects to Oracle with the same account (and privs).
I would rather set up our applications so that the database connection(s) are created at run time and connect to the actual Oracle account of the application user.
I realize that we might lose the performance benefits of pooling, but all of our applications prior to EJB have set up individual onnections at run time without creating performance problems.
Can this be done in WebLogic, and can anybody give me advice on how to do it? Or, is there a better idiom to follow in the EJB world?
Dave Segal
Ken Robinson
Ranch Hand

Joined: Jul 25, 2002
Posts: 52
While EJBs can be Local, they are really meant to run in a distributed world. As Connection objects cannot be passed from machine to machine, the Connection must be created in the same VM as the EJB, which is why the EJB container usually handles the Pooling.
Depending on how you've implemented your JDBC code, you may have an easy work around. If you've placed all the JDBC code in classes other than the EJB, you can just not use the EJBs. I usually create three sets of classes, one class for the data coming/going to/from the database, one class that holds all SQL and methods for creating the data beans via the SQL (usually only static methods that require a Connection as a parameter) and one set of classes that are the EJBs. The EJB remote/local interfaces usually miror the static SQL methods, without the need for a Connection object. The EJB gets a Connection from the pool and calls the static method in the DataAccessObject, returning the DataBean. If you implement this, you can cut out the EJBs, handle Connection creation yourself (from servlet, thick client) and just use the DAO/DataBeans.
Hope this helps and good luck.
I agree. Here's the link: http://aspose.com/file-tools
subject: EJB connection pools vs. Individual Oracle logins
It's not a secret anymore!