This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes How to call database stored procedures using EJB ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to call database stored procedures using EJB ??" Watch "How to call database stored procedures using EJB ??" New topic
Author

How to call database stored procedures using EJB ??

Rashmi Banthia
Ranch Hand

Joined: Dec 22, 2003
Posts: 79
I have another novice question. How to call database stored procedures in EJB? Can I use CMP and also call stored procedures ?? Any articles or books which explains this.
Thank you for your responses.
Regards,
Rashmi
Jason Stull
Ranch Hand

Joined: Feb 02, 2004
Posts: 47
That's the catch with CMP Entity Beans. The container will write the SQL for you. Most container vendors, I would imagine, will not let you hack the logic that generates the SQL statements (Although you should check the docs for your container). The db relationships in our shop are complex so we use BMP Entity Beans with Data Access Objects (DAOs) which use stored procedures.


"I believe in coyotes and time as an abstract Explain the change the difference between What you want and what you need there's the key"
Edy Yu
Ranch Hand

Joined: Nov 21, 2000
Posts: 264
I think you can still use stored procedure in CMP entity beans. CMP will take care of the persistence for your fields. But I think it's ok to have a few concrete methods in your beans class which has some calls to the stored procedure.


<i><br />Sun Certified Programmer for Java 2 Platform (SCJP)<br />Sun Certified Developer for Java 2 Platform (SCJD)<br />Sun Certified Web Component Developer for Java2 Platform, Enterprise Edition (SCWCD)<br />Sun Certified Business Component Developer for Java2 Platform, Enterprise Edition (SCBCD)<br />Sun Certified Enterprise Architect for J2EE (SCEA)<br />IBM Certified Enterprise Developer, WebSphere Studio V5.0<br /></i>
Rashmi Banthia
Ranch Hand

Joined: Dec 22, 2003
Posts: 79
Does this mean I have to use JDBC calls to execute a stored procedure ?
Does EJB-QL support exec procedure statement ??
Regards,
Rashmi
Ken Boyd
Ranch Hand

Joined: Dec 10, 2003
Posts: 329
As of I know EJB-QL doesn't support direct call to store procedure. If you look at theory how EJB-QL know about Oracle or any other db provider function? It's up to container to provide such access method. But again I am not completely sure with CMP.
You can do that BMP because container will tell when to sync with db & bean provider will write all SQL related code. In that case you will use java.sql.* (or other) API to make db connection & call to store procedure. I mean it becomes JDBC programming from that point.
Hope this help.


SCJP, SCWCD, SCBCD, SCJD, BB Java2 and JSP1.1
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to call database stored procedures using EJB ??
 
Similar Threads
Calling database stored procedures using EJB
AJAX In Practice: implementing pagination?
Calling stored procedures from EJB using JPA, is this possible ?
Calling stored procedures from Session bean's business methods
Calling Stored Procedures from EJB