Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

Testing banner

Plsql object type pass directed to java method without Connection string

1bb740b4-bb0e-4159-9134-ef175980e386Nov 13 2018 — edited Nov 19 2018

I would like to pass the plsql object type pass to Java. Java will get this object and after modification, I want to pass back the same object to plsql. Main program will be calling from plsql to Java and the expecting result return from java is to same object at plsql. May I know if there is anyway to ? Following is the code that I'm trying on it. Can plsql object type directly to java method/function as in and out paramter Without connection string . I tried to pass the plsql object type with Struct, it can able to compile the program. However, I do not know how can java accept this object and to be converted to java object.

Something like below example. Thank you very much

PL/SQL object Type

CREATE OR REPLACE TYPE Address AS OBJECT

( street VARCHAR2(30),

   city VARCHAR2(20)

);

PL/SQL Package calling java program

create or replace package body TYPE_ADD_TEST is

FUNCTION Test_ADD(in_address IN address

                ) RETURN address IS

LANGUAGE JAVA

NAME 'TestPrg.TestAddress(java.sql.Struct

                   ) return java.sql.Struct';

end TYPE_ADD_TEST;

Java code

create or replace and compile java source named testprg as

import java.util.*;

import java.io.*;

import java.sql.*;

public class TestPrg{

    public static String TestAddress(Struct TestAddress) {

        Address testAdd = (Address) TestAddress;

        // Address testAdd = new Address("s","c");

        return testAdd.street;

    }

}

Java Object Class

create or replace and compile java source named address as

import java.util.*;

import java.io.*;

public class Address {

    public String street ;

    public String city; 

    public Address() {}

    public Address(String a, String  b) {

        street = "java street";

        city = "java city";

    }

}

Thank you very much

Comments
Post Details
Added on Nov 13 2018
1 comment
957 views