• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

MDBs with a JDBC conneciton

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've got a design issue.
Should I make JDBC calls on the MDBs or 'outsourced' it to a Stateless Session Beans?
You see, the code has
public void ejbCreate() throws CreateException {
try {
InitialContext ic = new InitialContext();

dataSource = (DataSource) ic.lookup(JNDI_DATASOURCE);

ic.close();
And the onMessage has got JDBC calls and closing the connection once done, etc.

QUESTION: Is it going to be inefficient to have such JDBC stuff for a MDBs that listens to hundreds of messages from a given Queue?
What's your recommendation....to have them passed on to a pool of stateless beans to handle to JDBCs?
Thank you.
 
Ranch Hand
Posts: 2713
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My recommendation would be to break out the database logic into a DAO and directly call that from the MDB. I wouldn't go with a Session Bean unless it provides some type of concrete benefit for you (the need for declarative transactioning, security, etc.).
In regards to your performance question... how could using a Session Bean be faster than straight JDBC? Either way the same JDBC code is going to execute, however with a Session Bean you will need to factor in the added overhead of EJB.
reply
    Bookmark Topic Watch Topic
  • New Topic