This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes JDBC and the fly likes JDBC in Servlets or EJB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC in Servlets or EJB" Watch "JDBC in Servlets or EJB" New topic
Author

JDBC in Servlets or EJB

shaf kan
Greenhorn

Joined: Mar 29, 2006
Posts: 2
I have done certification in java web component development and now trying to work on the databases.
Someone told me that in java the databases can be retrieved and updated more properly in EJB as compare to Servlets.
Can someone tell me is there any difference between the two while working on the databases. Is there any performance issue.

Thanx
Eduardo Dela Rosa
Greenhorn

Joined: Apr 15, 2004
Posts: 25
Hi Shaf,

One of the things for sure is the Transaction support that EJB provides.

Relating to your concern, which is database, EJB provides ACID support that makes your data consistent.

Although there are other frameworks that can help you mimick the capability, such as Hibernate.

Cheers!


Eduardo dela Rosa<br />SCJP 1.4
Masoud Kalali
Author
Ranch Hand

Joined: Jul 08, 2004
Posts: 531


omeone told me that in java the databases can be retrieved and updated more properly in EJB as compare to Servlets.

you can use an EJB inside a servlet or use plain JDBC from within a Servlet , so these two are different stuff. servlet is in use for processing request that comes across the web and EJB is an standard for Persistance mechanism.
Indeed you can access to database from servlet by means of both ORM frameworks like Hibernate ,Ibatis, .... and Also by means of Entity beans that is Standard way and is discussed very widely..


Can someone tell me is there any difference between the two while working on the databases. Is there any performance issue.


different is that you will need more knowledge of Entity beans to write an application that use EJBs as persistance mechanism.
usually we use EJBs when we need some certain features like .
application must be work in distributed Env.
application should handle very larg amuont of transaction.
application should communicate with both web front end and Swing front end (both communicate with sesion beans or Entitie directly)
....

So , if you are new to Java database , i suggest you go with plain JDBC to access you data.


Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC in Servlets or EJB