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.