IBM Support

Creating and Deploying a Java Stored procedure in IBM Data Studio

Product Documentation


Abstract

Steps to create and deploy a Java Stored procedure in IBM Data Studio

Content

Prerequisites
The supported versions of Db2 for z/OS are Db2 11 for z/OS and Db2 12 for z/OS.

To build and deploy Java Stored Procedure, JDK and JRE with latest versions should be present in the system. The supported versions of Java on z/OS.

  1. From the Db2 11 for z/OS Program Directory:  Applications or stored procedures written in Java, such as those using the JDBC or SQLJ interfaces to Db2, require the IBM 31-bit SDK for z/OS, Java 2 Technology Edition V5 (5655-N98), or later, at run time.
  2. From the Db2 12 for z/OS Program Directory: Applications or stored procedures written in Java, such as those using the JDBC or SQLJ interfaces to Db2, require IBM 31-bit SDK for z/OS, Java Technology Edition, V6 (SDK6) (5655-R31), or later, at run time. Optionally, the following may be used for applications written in Java:
    • IBM 64-Bit SDK for z/OS, Java Technology Edition, V6 (SDK6) (5655-R32), or later, at run time.
    • Note: PIDs 5655-R31 and 5655-R32 are independent products and can coexist on the same z/OS system.

Steps to create a Java stored procedure

  1. Go to the Data Project Explorer panel, select Stored Procedures, and right-click and select New -> Stored Procedure.Creating a Java stored procedure

  2. In the New Stored Procedure panel, select the language as “Java”(by default, it is set to SQL).
    Setting the language to Java

  3. Select the template according to the description as per the requirement for your Java Stored Procedure and click Finish.
    Selecting a template

  4. A Java stored procedure named Procedure3 is created in the workspace.
    The new Java stored procedure

  5. Edit the .java file and save.

Steps to deploy a Java stored procedure (in Db2 for z/OS)

  1. In the Data Project Explorer, select Stored Procedures, right-click and select Deploy... to build this stored procedure on the target database.

    Selecting Deploy


  2. Select the stored procedure to be deployed and click Next.Selecting a routine to deploy

  3. The Deploy Routines wizard opens.

    Ensure that the Use current database radio button is selected in the Target database frame.

    If you want to deploy this routine on a different database from the one your database development project was bound to when it was created, select the Use different database radio button and use the Database drop-down list to select a database where this stored procedure should be built.

    The Deploy Routines wizard

    You can use the Schema field in the Target schema for deploying an unqualified routine box to specify the schema for the stored procedure.

    Select the Treat duplicates as errors radio button in the Duplicate handling box.

    Specify the target schema for unqualified routines

    You can tell IBM Data Studio what to do when you try to deploy a stored procedure on a database where a stored procedure with the same name within the same schema already exists. If you select the Drop duplicates radio button, IBM Data Studio will drop the existing stored procedure and create a new one with the same name using the Java code in your project.

    You can deploy multiple stored procedures in a single deployment using IBM Data Studio as well. If you select the Ignore duplicates and continue to the next routine radio button, IBM Data Studio will simply skip any stored procedures with the same name and build those that are unique on the target database.

    Select the Deploy by building the source radio button to do a full build of the stored procedure. Deploy the Java source and the binaries to the database. Now click Next.

    Deploying by building the source of by using binaries

  4. In the Deploy Routines window, some fields in the Routine options and Deploy options tabs are selected by default but can be changed.

    Specify routine options


  5. On the Routines Options page, in the Deploy options tab select the Build Utility if needed.

    Select the Enable debugging check box so you can leverage the distributed debugging capabilities that are part of IBM Data Studio. Click Finish.

    Saving the selected routine options 

  6. Check the SQL Results tab to see the deployment status.

    SQL for deploying the stored procedure

Differences while Deploying in Db2 for LUW and Db2 for z/OS

The process for creating a stored procedure is the same for both databases. While deploying there is only one difference the Deploy Routines window.
  • In Db2 for z/OS, you can customize options such as the WLM environment, ASU time limit, deployment options, and adding a java path.
  • In Db2 for LUW, the Deploy Routines window has only the following captured options:
Image 13

Document Location

Worldwide


[{"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SS62YD","label":"IBM Data Studio"},"Component":"","Platform":[{"code":"PF033","label":"Windows"}],"Version":"All versions","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

More support for:
IBM Data Studio

Software version:
All versions

Operating system(s):
Windows

Document number:
884548

Modified date:
09 January 2024

UID

ibm10884548

Manage My Notification Subscriptions