Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB using Stored Procedure?

 
ramana kittu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Study the Data Access Object object-oriented design pattern.
 
ramana kittu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
could you please tell me that websites for related that stored procedure callin with EJB.

Thanks,
Ramanakittu
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot clark,
 
Sarma Lolla
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic