Calling API Models

Wrapper API

The Wrapper API is generated by the Raw JDBC Connector Builder. It exposes static methods (no service interfaces), and the first parameter is always a JDBC connection. Transaction handling is not provided-you implement it yourself, which gives you full control. This model is best suited for complex, multi-step workflows executed within a single transaction, and for integration tests.

Java Calling Class : BinaryTypesWrapperApi.java
package plsql_workbench_examples.rawjdbcwrapper;

import java.sql.Connection;
import java.sql.DriverManager;

import transferobject.BinaryTypesTO;
import wrapper.BinaryTypesWrapper;

public class BinaryTypesWrapperApi {
  public static void main(String[] args)
  {
    try {
      Class.forName("oracle.jdbc.driver.OracleDriver");

      try (Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.109:1521/orcl",
                                                               "dbw_examples",
                                                               "dbw_examples"))
      {
        // calling the stored procedure
        BinaryTypesTO binaryTypesTO = BinaryTypesWrapper.call(connection, 1f, 1d, 1);

        // print values
        System.out.format("%.12f   %.12f   %d%n",
                          binaryTypesTO.getOBinFloat(),
                          binaryTypesTO.getOBinDouble(),
                          binaryTypesTO.getReturnValue());
      }
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}

Factory API

The Factory API is generated by all PL/SQL Connector Builders except the Raw JDBC Connector Builder. Configuration is done programmatically, and no additional framework dependencies are required (beyond the connector itself). The exact configuration options depend on the chosen connector type. The calling pattern is consistent across connector builder types: a factory creates and returns a service interface, which you use to invoke PL/SQL programs.

Java Calling Class : ScalarTypesFactoryApi.java
package plsql_workbench_examples.factoryapi;

import factory.ExamplesRPCFactory;
import service.ScalarTypesService;

public class ScalarTypesFactoryApi {
  public static void main(String[] args)
  {
    try {
      // set database credentials and configuration parameters
      System.setProperty("dbw_examples.url", "jdbc:oracle:thin:@192.168.0.109:1521/orcl");
      System.setProperty("dbw_examples.username", "dbw_examples");
      System.setProperty("dbw_examples.password", "dbw_examples");

      // get the service
      ScalarTypesService service = ExamplesRPCFactory.getScalarTypesService();

      // call the stored procedure and prints the result
      int sum = service.addNum(1, 2);
      System.out.println("sum:" + sum);

      // call the stored procedure and prints the result
      String concat = service.concatChar("A", "B");
      System.out.println("concat:" + concat);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}

Spring API

The Spring API is generated by all PL/SQL Connector Builders except the Raw JDBC Connector Builder. Configuration is declared using Spring configuration, so Spring must be available on the classpath. The exact configuration settings depend on the chosen connector type. As with the other builders, the calling pattern stays the same: you call PL/SQL programs through a service interface. In this model, the service interface is injected (for example, via annotations).

Java Calling Class : ScalarTypesSpringApi.java
package plsql_workbench_examples.springapi;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.stereotype.Component;

import service.ScalarTypesService;

@Component
public class ScalarTypesSpringApi {
  @Autowired
  private ScalarTypesService scalarTypesService;

  public static void main(String[] args)
  {
    // set database credentials and configuration parameters
    System.setProperty("dbw_examples.url", "jdbc:oracle:thin:@192.168.0.109:1521/orcl");
    System.setProperty("dbw_examples.username", "dbw_examples");
    System.setProperty("dbw_examples.password", "dbw_examples");

    // Register Spring Beans, Spring Context and call demo method 
    try (GenericApplicationContext ctx = BaseSpringConfig.getCtx(ScalarTypesSpringApi.class)) {
      ctx.getBean(ScalarTypesSpringApi.class).runDemo();
    }
  }

  private void runDemo()
  {
    try {
      // call the stored procedure and prints the result
      int sum = scalarTypesService.addNum(1, 2);
      System.out.println("sum:" + sum);

      // call the stored procedure and prints the result
      String concat = scalarTypesService.concatChar("A", "B");
      System.out.println("concat:" + concat);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}

Java EE / MicroProfile Beans

The Java EE Connector Builder can generate stateless or stateful session beans using container-managed or bean-managed transactions. Stateless beans behave similarly to the Factory and Spring APIs. Stateful beans are useful when you need explicit control over transaction boundaries while executing a longer business process.