File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC in Servlets or EJB

 
shaf kan
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic