Popularity
2.3
Growing
Activity
2.1
-
16
4
9

Description

OBridge is a Java source code generator for calling Oracle PL/SQL procedures and functions. It supports PL/SQL object types too.

Code Quality Rank: L5
Programming language: Java
Tags: Database     Oracle     Generator    
Latest version: v1.4

OBridge alternatives and similar libraries

Based on the "Database" category

Do you think we are missing an alternative of OBridge or a related project?

Add another 'Database' Library

README

OBridge

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:

  • BINARY_INTEGER
  • BOOLEAN
  • CHAR
  • CLOB
  • BLOB
  • DATE
  • NCHAR
  • NUMBER
  • NVARCHAR2
  • OBJECT - Oracle Object Type
  • PLS_INTEGER
  • TABLE - Table of Oracle Object Type
  • TIMESTAMP
  • VARCHAR2
  • 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.

Usage

Download the latest version from releases.

After downloading, create an XML configuration file:

<configuration>
    <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 -->
    <packages>
        <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 -->
    </packages>
</configuration>

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

}