Deploy SQLJ applications that use bean-managed persistence
To deploy SQLJ applications that do not use container-managed persistence...
- Translate the SQLJ application to configure for the appserver environment
- Customize the SQLJ profiles
New feature: The appserver includes these new features for SQLJ support for applications that use bean-managed persistence:
- Customize SQLJ profiles with the admin console or scripting.
- Customize SQLJ applications again without needing to reinstall the application.
Procedure
- Create a backup copy of the .java file.
For example if the file is called MyServlet.java, copy MyServlet.java to MyServlet.java.bkup.
- Rename the .java file to a file name with a .sqlj extension.
For example, rename MyServlet.java to MyServlet.sqlj
- Edit the .sqlj file to convert the JDBC syntax to SQLJ syntax.
When using SQLJ, if we want connection management for the appserver to function properly, specify correct connection contexts.
For example, convert the following JDBC operation:
Connection con = dataSource.getConnection(); Statement stmt = con.createStatement(); stmt.execute("INSERT INTO users VALUES (1, 'user1')"); con.commit();...to the following SQLJ...
// At the top of the file and just below the import statements, define Connection_Context #sql context Connection_context; . . Connection con = dataSource.getConnection(); . . Connection_context ctx1 = new Connection_context(con); . . #sql [ctx1] {INSERT INTO users VALUES (1, 'user1')}; . . con.commit(); ctx1.close();When you run the SQLJ translator, the .java file that the tool creates will have the same name as the old .java file, providing you with a seamless transition to the SQLJ technology.
- From the DB2 installation, copy the sqlj.zip file to a directory on the workstation.
Modify the Java build path of the JAR file project to include the sqlj.zip file.
- Use RAD or the DB2 SQLJ translator to automatically translate SQLJ.
- Use RAD:
- In the Project Navigator, right-click the JAR project, and select Add SQLJ Support....
- Select the boxes for the applications for which you want SQLJ support.
- In the SQLJ JAR file field, type the fully qualified path to the sqlj.zip file that you previously copied to the workstation.
- Click Finish.
- Export the EAR file.
- Use the DB2 SQLJ translator.
This tool creates a .java version of the .sqlj file and a serialized profile, with a .ser extension, used later in processing.
- Package the JAR file for the enterprise application.
- Install the application onto the appserver, or customize the profiles with the db2sqljcustomize tool.
To customize the profiles with the appserver....
- Package the JAR file for the enterprise beans, servlets, and any .ser files into an enterprise archive.
- Install the application in the appserver and customize SQLJ profiles with the admin console or wsadmin.
Avoid trouble: Do not select Deploy enterprise beans during the application installation process in the admin console. If we redeploy the enterprise beans from the admin console, you will lose the customization changes that we have made.
The appserver provides enhanced support for SQLJ applications. Install the SQLJ application in the appserver , and we can customize and bind SQLJ profiles through the admin console or scripting:
Related tasks
Data access beans
Customize profiles for SQLJ applications
Customize SQLJ profiles with the db2sqljcustomize tool
Deploy SQLJ applications that use CMP
Deploy SQLJ applications that use CMP with the ejbdeploy tool
RAD: Developing SQLJ applications
Related
Application management
Exceptions pertaining to data access