Skip to content
Philippe Marschall edited this page Apr 25, 2020 · 23 revisions

The purpose of the stored-procedure-proxy library is to make calling SQL stored procedures from Java easy and type safe. To call a stored procedure you need to do two things:

  1. create an interface that represents the stored procedures you want to call
  2. create and instance of the interface

The interface is a simple POJO interface. If for example you have a salesTax stored procedure that takes a NUMBER and returns a NUMBER the interface declaration would look like this:

public interface TaxProcedures {

  BigDecimal salesTax(BigDecimal subtotal);

}

The instance can be created using only a javax.sql.DataSource

TaxProcedures taxProcedures = ProcedureCallerFactory.build(TaxProcedures.class, dataSource);

Invoking the interface method will then call stored procedure.

taxProcedures.salesTax(new BigDecimal("100.00"));

will actually call the stored procedure.