RSS Forums RSS
Please support our Java advertiser: Lunarpages Java Web Hosting

How to call a EJB method from Session bean method

Join Date: Sep 2006
Location: India
Posts: 79
Reputation: parthiban is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 6
parthiban's Avatar
parthiban parthiban is offline Offline
Junior Poster in Training

Help Re: How to call a EJB method from Session bean method

  #3  
Mar 28th, 2007
Originally Posted by jwenting View Post
You don't.
You create a new entity, and it takes care of its database access itself.


Hi Jwenting ,
First of all thanks for your reply . I think i didn't correctly specified what i need .

Task i need to accomplish :
=================
I have to read ACCESS tables and EXCEL sheets to convert in to XML file so that i can store that values in SQL SERVER using JOnAS Application Server .

Here's my story which will tell what i need :
===========================

I created SESSION BEAN program which contains function which will convert ACCESS/EXCEL file in to XML .

I also created ENTITY BEAN program which contains function to store the data in SQL SERVER(the data which are obtained from that XML file).

i have developed that ENTITY module in such a way that i need to pass the data as arguments of create method of that ENTITY BEAN as follows .


public String ejbCreate(String empid, String firstname, String lastname, String circle, String subcircle, String created_date, String updated_date) throws CreateException {
        try{
            insertRow(empid,firstname,lastname,circle,subcircle,created_date,updated_date);
        }catch(SQLException ex){
            throw new EJBException("ejbCreate: " + ex.getMessage());
        }
        this.empid = empid;
        this.firstName = firstname;
        this.lastName = lastname;
        this.Circle = circle;
        this.Subcircle=subcircle;
        this.Created_Date=created_date;
        this.Updated_Date=updated_date;
        return empid;
        
    }

private void insertRow(String empid, String firstName,
            String lastName, String Circle,String Subcirle,String Created_Date,String Updated_Date) throws SQLException{
        makeConnection();
        String insertStatement = "insert into Employee values ( ? , ? , ? , ?,?, ?,? )";
        PreparedStatement prepStmt = con.prepareStatement(insertStatement);
        
        prepStmt.setString(1, empid);
        prepStmt.setString(2, firstName);
        prepStmt.setString(3, lastName);
        prepStmt.setString(4, Circle);
        prepStmt.setString(5, Subcircle);
        prepStmt.setString(6,Created_Date);
        prepStmt.setString(7,Updated_Date);
        
        
        prepStmt.executeUpdate();
        prepStmt.close();
        releaseConnection();
    }


What i planned to fetch XML data:
=====================

I will develop a function to parse XML file in that SESSION BEAN ( which created that XML file) to obtain that data and i have to pass that values to the above function which is in ENTITY BEAN.

I came to know that i can't invoke create method of ENTITY bean so i need to invoke that insertRow function directly (which actually stores data in SQL SERVER) .

So please guide me HOW CAN I INVOKE a ENTITY BEAN method (insertRow) from an SESSION BEAN with sample coding .

I think it's quite a big story .Thanks for your patience

Thanks in advance.
Reply With Quote  
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 9:55 am.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC