< Prev - Documentation - Next >

Calling API Models

Wrapper-API

The Wrapper-API is generated by the Raw JDBC Connector Builder. The methods are directly implemented as static methods without service interfaces. The first parameter is always the connection. The transaction handling must be implemented additionally but allows full control of the transaction handling. Best useage is for multiple complex calls inside one transaction or 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.102: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 be generated from any other PL/SQL Connector Builder other than the Raw JDBC Connector Builder. All configurations are set programmatically. No other depended libraries have to be bound to the project. The configuration settings depends on the connector type. The useage to call the PL/SQL stored procedure is identical for all connector builder types. The factory returns a service interface to invoke the service call to the PL/SQL stored procedure.
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 {
      // 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 be generated from any other PL/SQL Connector Builder other than the Raw JDBC Connector Builder. All configurations are declared. Of course Spring must be included to the project. The configuration settings depends on the connector type. The useage to call the PL/SQL stored procedure is identical for all connector builder types. The service interface is injected via annotation. Thru the service interface to PL/SQL stored procedure is called.
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) {
    // 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 JEE-Beans

The Java JEE Connector Builder supports creation of CMP (Container Managed Persistent) or BMP (Bean Managed Persistent) stateless or stateful session Java EE Beans. BMP stateless session Java EE Beans will behave identically to the Factory-API and Spring-API calls. Then you generate CMP statefull session Java EE Beans you have full control of the transaction then performing you business process.

< Prev - Documentation - Next >