Why and when to perform this task
This article describes how JDBC applications, comprised of Bean Managed Persistence (BMP) beans or servlets, are converted to SQLJ applications. It also describes how the SQLJ applications are then deployed in WebSphere Application Server.Follow these steps precisely and in the right order to ensure a correct conversion:
Steps for this task
Now when you run the sqlj tool in the next step, the .java file that it creates will have the same name as your old .java file, providing you with a seamless transition to the SQLJ technology.
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 DB2 SQLJ customizer against the serialized profiles, you create static SQL in the database, which is used at runtime. The customization phase creates four database packages that contain static SQL, one for each isolation level.