aspose file tools*
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 Spring in Action this week in the Spring 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.


SCJP, SCJD, SCWCD, SCBCD, SCEA, IBM Certified Enterprise Developer, WebSphere Studio V5.0
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
 
Don't get me started about those stupid light bulbs.
 
subject: How to call database stored procedures using EJB ??