Deploy SQLJ applications
Use Structured Query Language in Java (SQLJ) to develop data access applications that connect to DB2 databases. SQLJ is a set of programming extensions that enable you to use the Java programming language to embed statements that provide SQL (Structured Query Language) database requests.
The advantages of developing applications with SQLJ include improved performance and a shorter, more efficient development cycle. We can achieve the following with SQL:
- Improve performance by using static SQL statements.
- Reduce the development cycle:
- Write less code with the simpler SQLJ syntax, which reduces the number of lines of code required to execute statements, set parameters, and retrieve parameters.
- Detect programming errors earlier in the development phase with the online check function, which performs data type validation and schema validation. See the DB2 documentation for a complete list of customization options.
Consider using SQLJ in situations where dynamic SQL is not needed, and where applications use DB2 as the database server.
The application server includes enhanced SQLJ support for applications that use container-managed persistence (CMP). The enhanced support includes the following items: include:
- Deploy CMP beans during the application installation in the application server.
- Customize and binding SQLJ profiles with the console or scripting.
- Customize and binding SQLJ applications again without needing to reinstall the application.
These enhancements reduce the complexity of installing, deploying, and customizing SQLJ applications for both container-managed and bean-managed persistence.
- Acquire the required drivers to deploy an SQLJ application in the application server. You need the following files, depending on the JDBC provider that you use:
JDBC provider type Required files DB2 Using IBM JCC Driver This driver is also known as:
- IBM Data Server Driver for JDBC and SQLJ
- IBM DB2 Driver for JDBC and SQLJ
- IBM DB2 Universal JDBC Driver.
db2jcc.jar or db2jcc4.jar DB2 Universal JDBC driver (deprecated) db2jcc.jar
- Deploy the SQLJ application.
- Deploy applications that use container-managed persistence (CMP):
- Deploy SQLJ applications that use container-managed persistence (CMP) with the DB2 Using IBM JCC Driver.
- Deploy SQLJ applications that use container-managed persistence (CMP) with the ejbdeploy tool.
- Deploy SQLJ applications that use bean-managed persistence, servlets, or sessions beans.
- Use embedded SQLJ with the DB2 for z/OS Legacy driver (deprecated).
- Customize and bind the SQLJ profiles. Before the application server can use an SQLJ application, the SQLJ statements must be processed for the database server. By default, four DB2 packages are created in the database; one package is created for each isolation level. The customization process augments the profiles with information that is specific to the database. If we do not customize the SQLJ profiles, the SQLJ application uses dynamic SQL like a JDBC application.
- Customize and binding profiles for Structured Query Language in Java (SQLJ) applications.
- Customize and bind SQLJ profiles with the wsadmin scripting tool. See the topic, Customizing and binding SQLJ profiles with wsadmin.sh.
- Customize and binding SQLJ profiles with the db2sqljcustomize tool.
Subtopics
- Deploy SQLJ applications that use container-managed persistence (CMP)
Embed Structured Query Language in Java (SQLJ) statements in the applications to maximize the efficiency of transactions with the databases. Before the applications can take advantage of SQLJ, you must deploy the application and customize the SQLJ profiles created. The application server provides functionality to use SQLJ as the persistence mechanism for enterprise beans that use container-managed persistence. Deploy the CMP beans in the application server to enable SQLJ support.
- Deploy SQLJ applications that use bean-managed persistence, servlets, or sessions beans
We can embed Structured Query Language in Java (SQLJ) statements in the applications to maximize the efficiency of transactions with the databases. Before the applications can take advantage of SQLJ, deploy the application and customize the created SQLJ profiles. We can use Rational Application Developer or the DB2 SQLJ translator to translate the application before deploying it on the application server.
- Customize and binding profiles for Structured Query Language in Java (SQLJ) applications
Simplify the process of customizing and binding SQLJ profiles for the applications by performing these functions in the console or . SQLJ profiles must be customized and bound before the enterprise application can use the application's embedded SQL.
- Use embedded SQLJ with the DB2 for z/OS Legacy driver
Structured Query Language in Java (SQLJ) is a set of programming extensions that enable a programmer, using the Java programming language, to embed statements that provide Structured Query Language (SQL) database requests. We can use the DB2 for z/OS Legacy driver with the data access applications.
- Directory conventions
References in product information to app_server_root, profile_root, and other directories imply specific default directory locations. Become familiar with the conventions in use for WebSphere Application Server.
Related tasks
Deploy SQLJ applications that use container-managed persistence (CMP) with the ejbdeploy tool Customize and binding SQLJ profiles with the db2sqljcustomize tool
Rational Application Developer: Developing SQLJ applications
Application management (AdminTask)