Entering content frame

Procedure documentation Developing the Data Access Interface Locate the document in its SAP Library structure

Use

In this example you are going to implement data access using either SQLJ or JDBC. Therefore, you need to develop the DAO interface for database access, which enables you to choose between SQLJ and JDBC at runtime.

Prerequisites

You must have developed the EmployeeData class.

Procedure

I...

       1.      In the Java perspective, choose GettingStartedOpenSQLWeb project and open its context menu.

       2.      Choose New ® Interface. To choose a package, use Browse… next to the Package field, and select temp.persistence.gettingstarted.dao from the list.

       3.      Enter DAO in the Name field and choose Finish.

       4.      The Java file is created and opens automatically. Enter the code of the interface.

Example

package temp.persistence.gettingstarted.dao;

 

import java.sql.SQLException;

 

public interface DAO {

  

   public void createDepartment(int depId, String depName) throws SQLException;

  

   public void createEmployee(EmployeeData employee) throws SQLException;

  

   public EmployeeData[] getEmployeesFromDepartment(int depId) throws SQLException;

  

   public void commit() throws SQLException;

  

   public void rollback() throws SQLException;

  

   public void close() throws SQLException;

 

}

 

       5.      Save and close the file.

Result

You have created a data access interface. First, you are going to implement the interface using SQLJ. Go on with creating an SQLJ connection context class.

 

 

Leaving content frame