Fetching contributors…
Cannot retrieve contributors at this time
95 lines (75 sloc) 2.96 KB


PayPal donate button

OBridge provides a simple Java source code generator for calling Oracle PL/SQL package procedures.

Supported input, output parameters and return values are:

  • CHAR
  • CLOB
  • BLOB
  • DATE
  • OBJECT - Oracle Object Type
  • TABLE - Table of Oracle Object Type
  • RAW

The following types cannot be implemented, because JDBC driver does not supports them:

  • Types declared in source code
  • %ROWTYPE parameters

Generated code compiles with Java 1.6.


Download the latest version from releases.

After downloading, create an XML configuration file:

	<jdbcUrl>jdbc:oracle:thin:scott/tiger@localhost:1521:xe</jdbcUrl> <!-- jdbc connection string for obridge -->
	<sourceOwner>SCOTT</sourceOwner> <!-- owner of the database objects -->
	<sourceRoot>.</sourceRoot> <!-- where to generate sources - related to this configuration file -->
	<rootPackageName>hu.obridge.test</rootPackageName> <!-- root Java package, generator builds the directory structure -->
		<entityObjects>objects</entityObjects> <!-- object types are going to this package -->
		<converterObjects>converters</converterObjects> <!-- converter util classes are going to this package -->
		<procedureContextObjects>context</procedureContextObjects> <!-- procedure parameter entities are going to this package -->
		<packageObjects>packages</packageObjects> <!-- procedure calling utility classes are going to this package -->

Run the generator:

java -jar obridge.jar -c <obridge-config.xml>

OBridge connects to the specified database and generates the required classes.

Calling a PL/SQL procedure

For example you have the following PL/SQL code:

Create Or Replace Package simple_procedures is
  Function simple_func(a In Varchar2,
					   b In Out Varchar2,
					   c Out Varchar2) Return Number;
End simple_procedures;

Generated source:

public class SimpleProcedures {
	public static SimpleProceduresSimpleFunc simpleFunc(String a, String b,  Connection connection) throws SQLException { ... }

You can call the SimpleProcedures.simpleFunc method:

SimpleProceduresSimpleFunc ret = SimpleProcedures.simpleFunc("hello", "world", conn); // conn is the database connection

Return object will hold the input and output parameters, converted to Java types.

public class SimpleProceduresSimpleFunc {

	private BigDecimal functionReturn;
	private String a;
	private String b;
	private String c;
	// getters, setters