Deploying SQLJ applications that use bean-managed persistence, servlets, or sessions beans

Embed Structured Query Language in Java (SQLJ) statements in your applications to maximize the efficiency of transactions with your databases. Before your applications can take advantage of SQLJ, you must deploy the application and customize the SQLJ profiles that are created. You can use Rational® Application Developer (RAD) or the DB2® SQLJ translator to translate the application before you deploy them on the application server.

Before you begin

Create an SQLJ application using Rational Application Developer or another development tool.

About this task

To deploy SQLJ applications that do not use container-managed persistence, you need to translate the SQLJ application first to configure it for the application server environment. After translation, you can choose to customize the SQLJ profiles in the application server, with scripting, or with the db2sqljcustomizer tool.
New feature New feature: The application server includes these new features for SQLJ support for applications that use bean-managed persistence:
  • Customizing and binding SQLJ profiles with the administrative console or scripting.
  • Customizing and binding SQLJ applications again without needing to reinstall the application.
newfeat

Procedure

  1. Optional: Create a backup copy of your .java file. For example if your file is called MyServlet.java, copy MyServlet.java to MyServlet.java.bkup.
  2. Optional: Rename your .java file to a file name with a .sqlj extension. For example, if your application is a servlet named MyServlet.java, rename MyServlet.java to MyServlet.sqlj
  3. Optional: Edit the .sqlj file to convert the JDBC syntax to SQLJ syntax. When using SQLJ, if you want connection management for the application server to function properly, you must 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 your old .java file, providing you with a seamless transition to the SQLJ technology.
  4. From your DB2 installation, copy the sqlj.zip file to a directory on your workstation. Modify the Java build path of your enterprise bean Java archive (JAR) file project to include the sqlj.zip file.
  5. Use Rational Application Developer or the DB2 SQLJ translator to automatically translate SQLJ.
    • Use Rational Application Developer:
      1. In the Project Navigator, right-click your JAR project, and select Add SQLJ Support....
      2. Select the boxes for the applications for which you want SQLJ support.
      3. In the SQLJ JAR file field, type the fully qualified path to the sqlj.zip file that you previously copied to your workstation.
      4. Click Finish.
      5. Export the enterprise archive (EAR) file.
    • Use the DB2 SQLJ translator. This tool creates a .java version of your .sqlj file and a serialized profile, with a .ser extension, that is used later in processing. Refer to the DB2 documentation for more information on the SQLJ translator tool.
  6. Package your JAR file for the enterprise application.
  7. Install the application onto the application server, or customize the profiles with the db2sqljcustomize tool.
    • Customize the profiles with the application server.
      1. Package the JAR file for your enterprise beans, servlets, and any .ser files into an enterprise archive.
      2. Install the application in the application server, and customize SQLJ profiles with the administrative console or the wsadmin tool.
        Avoid trouble Avoid trouble: Do not select Deploy enterprise beans during the application installation process in the administrative console. If you redeploy the enterprise beans from the administrative console, you will lose the customization changes that you have made.gotcha
        The application server provides enhanced support for SQLJ applications. Install the SQLJ application in the application server , and you can customize and bind SQLJ profiles through the administrative console or scripting:
        • To customize the SQLJ profiles with the administrative console, read the topic on customizing and binding profiles for Structured Query Language in Java (SQLJ) applications.
        • To customize SQLJ profiles with scripting, read the topic on the application management command group for the AdminTask object.
    • To use the db2sqljcustomize tool, read the topic on customizing and binding SQLJ profiles with the db2sqljcustomize tool for more information.



In this information ...


Related concepts

IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic Task topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Jun 11, 2013 8:40:09 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=v701sca&product=was-nd-mp&topic=tdat_deploybmp
File name: tdat_sqljdeploybmp.html