Show TOC Start of Content Area

Procedure documentation Creating the SQLJ Connection Context  Locate the document in its SAP Library structure

Use

To access the database using SQLJ, you need to create a connection context class Ctxthat is associated with a JDBC DataSource. At runtime, an instance of this class represents a database connection.

Prerequisites

You must have created the GettingStartedOpenSQLWeb project.

Procedure

O...

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

       2.      Choose New Other. Choose Persistence in the left-hand pane and SQLJ Source in the right-hand pane.

       3.      Choose Next.

       4.      Enter Ctx in the Name field. To choose a package, use Browse… next to the Package field, and choose temp.persistence.gettingstarted.dao from the list.

       5.      Choose Finish.

       6.      The SQLJ file opens automatically once it has been created. Enter the following code:

Example

package temp.persistence.gettingstarted.dao;

 

#sql public context Ctx with (dataSource = "java:comp/env/TMP_PERSISTENCE_EXAMPLE");

 

       7.      Save and close the file.

Result

You have created the SQLJ connection context for the example. Go on with creating the ResultSet iterator for the employee data.

 

End of Content Area