on 06-24-2009 1:36 PM
Hy @all,
i try to learn WebDynPro for Java. Therefore I leran some basics. Now: Database / SQLJ / EJB /
I have a EJB Project a Webproject and a application project. IN the EJB Project I have a sqlj Datei with DataAccess.
public class EmployeeDAO {
public static void main(String[] args) {
}
public void createEmployeeDAO (EmployeeDTO employeeDTO)
throws SQLException {
SQLJConnection connCtx = null;
try {
connCtx = new SQLJConnectionCtx();
#sql [connCtx] {insert into ja300_10employee
(employee_id, first_name, last_name, email)
values
(:(employeeDTO.getEmployeeId()),
:(employeeDTO.getFirstName()),
:(employeeDTO.getLastName()),
:(employeeDTO.getEmail()))
};
} finally {
if connCtx != null) {
connCtx.close();
}
}
}
}
But when I try to create an intance of the class the nwds says: can not resolve....
What goes wrong?
Hi,
Where you are creating object for EmployeeDAO class? In WebDynpro or in EJB project?
Are you using Development Components?
For example if you have created the EmployeeDAO in java DC and if you want to use this in EJB DC/WebDynpor DC , you need to add this class to the public part (api) and then you need to add this public part as used dc in the DC where you want to create the object.
Regards,
Charan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hy an thx for your help,
first of all I have set the reference to the projects. In the package: com.sap.training.dbaccess are the following files:
EmployeeDAO.sqlj
EmployeeDAO.java (empty)
EmployeeDTO.java
SQLJConnection.sqlj
SQLJConnection.sqlj (empty)
in the package: com.sap.training.ejb i have the SessionBean an in this class I want to have a reference to the EmployeeDAO object as follow:
public class EmployeeSessionBean implements SessionBean {
private EmployeeDAO employeeDAO;
public void ejbRemove() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void setSessionContext(SessionContext context) {
myContext = context;
}
private SessionContext myContext;
/**
* Business Method.
*/
public void createEmployee(EmployeeDTO employeeDTO)
throws EmployeeException {
try {
employeeDAO.createEmployee(employeeDTO);
} catch (SQLException e) {
e.printStackTrace();
throw new EmployeeException("Error while creating new employee: " + e.getMessage());
}
}
/**
* Create Method.
*/
public void ejbCreate() throws CreateException {
// TODO : Implement
employeeDAO = new EmployeeDAO();
}
}
The second line is the bad one An sqlj file i have to use, if i handle with dataaccess / sql statements. Can I have an instance of an sqlj class?
regards
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.