aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB using Stored Procedure? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB using Stored Procedure?" Watch "EJB using Stored Procedure?" New topic
Author

EJB using Stored Procedure?

ramana kittu
Greenhorn

Joined: Oct 14, 2008
Posts: 5
Hi All,

Any body know the ejb with stored procedue calling,

I have a ejb application, i need to implement stored procedure and use it in ejb, with weblogic server.

please help me out from this problem.

Thanks in advance.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Study the Data Access Object object-oriented design pattern.
ramana kittu
Greenhorn

Joined: Oct 14, 2008
Posts: 5
could you please tell me that websites for related that stored procedure callin with EJB.

Thanks,
Ramanakittu
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Everything about developing software is not on a "web site" waiting for you to find it with a ?oogle search.

If you learn about how to implement the Data Access Object design pattern and know how to program Enterprise JavaBeans, then you should not have any problem with executing a stored procedure from an Enterprise JavaBean.

Below is a guide to help you find what you are looking for.

ramana kittu
Greenhorn

Joined: Oct 14, 2008
Posts: 5
thanks alot clark,

My Application was alreay developed by somone,

the architecture is like struts-->ejbSessionBeans(Remotely)-->ejbEntityBeans(locally calling from sessionbeans ).

the above architecture is giving performance issue because there are looping business logic from session to entitybeans, so network tropic is arrived,

now i have to change my architecture for some part(2 or 3 sessionbeans) where the looping concept is came. the architecture is would be struts--->sessionbeans---->
PL/SQL Stored Procedure(Replace with Entity Beans),

1) so we need to write pl/sql stored procedure code(is required any configuration in ejb-jar.xml or else?)

2)how to access that pl/sql code in our SessionBeans?

3)how to do all thease configurations?

could you please tell me with example code if any body knows?

Thanks in advance,
RamanaKittu
Phani Raju
Greenhorn

Joined: Aug 03, 2007
Posts: 19
There are multiple ways of accomplishing this, below I list couple:

Using plain JDBC: You can write the jdbc code for calling the stored procedure using callable statements.

Using some ORM framework like Hibernate, IBatis etc. which allow the result of SP call to be mapped to a data object (a Java pojo class).
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
2)how to access that pl/sql code in our SessionBeans?


See my code example above. This method would be in your Session EJB.
ramana kittu
Greenhorn

Joined: Oct 14, 2008
Posts: 5
Thanks a lot clark,
Sarma Lolla
Ranch Hand

Joined: Oct 21, 2002
Posts: 203
This is how I am executing a stored procedure... you have to use Native query

private final static String my_query= "BEGIN my_pkg.my_proc(); commit; END;";

try{
Query query = em.createNativeQuery(my_query);
query.executeUpdate();
}
catch (Exception e){
e.printStackTrace();
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB using Stored Procedure?