How to return custJava Object from Java Stored Function/Procedure to Java Application

I WILL PAY $100 FOR SOLUTION.
Oracle JDBC documentation gives step by step on how to return Oracle Type Object to Java Application. No question here.
But is it possible to create Java Stored Function [getMyClass() ] which returns CUSTOM Java based object [MyClass] to Java application like:
//java stored function
class Foo
public static MyClass getMyClass()
return new MyClass();
//java class I want to return to Java
class MyClass
public String getGreetings(String name)
return "Hello " + name;
I tried to do it using intermittent Oracle
Type Object and OracleConnection map to make binding between Java->Oracle->Java. I could
not get throgh meaningless run time ORA Errors. Any kind of help would be greatly
appreciated. If you know the answer please
post it or e-mail [email protected]
null

You don't say which version of the database you are on. There's an interesting looking article on OTN on handling CLOBs in JDBC in 10g. It may well be useful for earlier versions too (but no guarantees).
Cheers, APC

Similar Messages

  • How to return a object from a method in a java program to a C++ call (JNI )

    Sir,
    I am new to java and i have been assigned a task to be done using JNI.
    My question is,
    How can i return an object from a method in a java program to a call for the same method in a C++program using JNI.
    Any help or suggesstions in this regard would be very useful.
    Thanking you,
    Anjan Kumar

    Hello
    I would like to suggest that JNI should be your last choice and not your first choice. JNI is hard to get right. Since the JNI code is executing in the same address space as the JVM, any problems (on either side) will take down the entire process. It dilutes the Write Once Run Anywhere (WORA) value proposition because you need to provide the JNI component for all hardware/OS platforms. If you can keep your legacy code(or whatever you feel you need to do in JNI) in a separate address space and communicate via some inter-process channel, you end up with a system that is more flexible, portable, and scalable.
    Having said all that, head over to the Java Native Interface: Programmer's Guide and Specification web page:
    http://java.sun.com/docs/books/jni/
    Scroll down to the Download the example code in this book in ZIP or tar.gz formats. links and download the example source. Study and run the example sources. The jniexamples/chap5/MyNewString demo creates a java.lang.String object in native code and returns it to the Java Language program.

  • How to get stylesheet object from JAVA RESOURCE stored in DB

    Hi,
    I stored a xslt file in the database and have a JAVA RESOURCE file now. How can i get a stylesheet object from this resource file?
    I took the following class to get an impression how to get the contents of the resource but -although the name of the resource was spelled correctly- i got a file not found exception.
    Whats wrong?
    public class PrintRessource {
    public static void print (String p_ressource){
    try {
    Class c = PrintRessource.class;
    System.out.println(c.toString());
    InputStream file = c.getResourceAsStream(p_ressource);
    if (file == null)
    throw new FileNotFoundException("XSLT file not in DB");
    byte[] buffer = new byte[4096];
    int bytes_read;
    while ((bytes_read = file.read(buffer)) != -1)
    System.out.println(new String(buffer, 0 , buffer.length));
    catch (Exception exp) {
    System.out.println(exp);
    Thanks

    The code works as is. I just forgot to add the slash in front of the Resource file name.

  • How to run a vi from Java application?

    I am passing data to a vi from my java swing application using data socket bean but I have to manually open and run the vi. How can I programatically open and run the vi from my java application without using ActiveX automation server?

    I don't know Java but if you can issue a shell command then you can run the VI with the command line:
    "\labview.exe" ""
    You have to set the VI to "Run when opened". The VI will run each time the command is issued, even if the VI is already opened.
    LabVIEW, C'est LabVIEW

  • How to call other execs from java application

    What is the best way to make a call to execute an external executable written in another language (i.e. c++ or ada95) from within a java application?

    Hi,
    Runtime.getRuntime().exec(new String[]{"C:\\Office\\winword.exe"});
    you should catch IOException as well.
    Phil

  • How to print PDF file from java application?

    Hi,
    I have a java application that needs to print an PDF files. Could any one provide me links to tutorial/sample codes for doing this?

    http://onesearch.sun.com/search/onesearch/index.jsp?qt=print+pdf+files&subCat=&site=dev&qp=&chooseCat=javaall&col=developer-forums

  • How to return ResultSet object from Bean to JSP

    I have a Java Bean, in it I have ResultSet Object in a method. Now I want to send this ResultSet Object to the JSP.

    very good advice, otherwise you will spread your sql exception handling over way too many places. Keep it centered, so you can be sure to close your connection, statement, resultset again. Otherwise your database and web application might all of a sudden stop responding.

  • How to call webservice from Java application

    Hi XI gurus
    Pls let me know how to call a webservice from Java application.
    I wanted to build synchronous interface from Java Application to SAP using SAP XI
    For example, i need to create Material master from Java application and the return message from SAP, should be seen in Java application
    Regards
    MD

    Hi,
    If your  JAVA Application is Web based application, you can expose it as Webservice.
    JAVA People will pick the data from Dbase using their application and will send the data to XI by using our XI Details like Message Interface and Data type structure and all.
    So we can Use SOAP Adapter or HTTP in XI..
    If you use HTTP for sending the data to XI means there is no need of Adapter also. why because HTTP sits on ABAP Stack and can directly communicate with the XI Integration Server Directly
    If you are dealing with the Webservice and SAP Applications means check this
    Walkthrough - SOAP  XI  RFC/BAPI
    REgards
    Seshagiri

  • Returning objects from Java stored procedures

    I need to pass an object from Java to a Java SP which updates the object and returns the object back. The Java SP will be calling a PL/SQL procedure which returns some nested tables that I want to stick into the passed object.
    I tried using "IN OUT" for the object in the call spec but got an error that it was not "appropriate for the parameter". So, the next option seems to be to pass it in and then return it from the Java SP. I'm just wondering though what the the best approach for accomplishing this? I've looked through some of the sample code on the OTN but haven't found anything yet that really helps.

    I am trying to use custom object classes. I have setup a type map for the connection and my custom class implements SQLData. Yet, when my client tries to call the Java SP, it gets ORA-00932 complaining of inconsistent data types (expected IN conversion failed).
    I turned on some debug info (i.e. oracle.jdbc.sql=true) but it didn't provide any useful info in regards to why I'm getting this error. Unfortunately, the JDBC Developer's Guide does not provide full examples of the code.

  • Help! How to convert an instance from java.lang.Object to a particula class

    * How to convert an instance from java.lang.Object class to a particular class
    witch is known only at the running time?
    Roster EJB component is make up of RosterHome, Roster and RosterBean.
    RosterHome is the home interface of Roster EJB.
    Roster is the remote interface of Roster EJB.
    RosterBean is the implement of Roster EJB.
    The following code segment is to invoke Roster EJB component.
    String jndiName="roster.RosterHome";
    javax.naming.Context initial = getInitialContext();//getInitialContext() returns a instance of Context.
    Object objref = initial.lookup(jndiName);
    RosterHome home =
    (RosterHome)javax.rmi.PortableRemoteObject.narrow(objref,
    RosterHome.class);
    Roster myRoster = home.create();
    String team="T1"
    String player="Tom"
    myRoster.addPlayer(player,team);
    But, now, all the home interface, the remote interface and the JNDI Name of
    Roster EJB component are not been known at the compiling time. However They are
    known at the running time, throught reading from the XML config file.
    Questions:
    1,How to write code for this case ? or
    2,How to convert an instance from Object class to a particular class witch is known
    only at the running time?
    String jndiName="roster.RosterHome";// in fact, reads from XML file.
    String homeClassName="roster.RosterHome";// in fact, reads from XML file.
    String remoteClassName="roster.Roster";// in fact, reads from XML file.
    javax.naming.Context initial = getInitialContext();//getInitialContext() returns a instance of Context.
    Object objref = initial.lookup(jndiName);
    Object objHome= javax.rmi.PortableRemoteObject.narrow(objref,
    Class.forName(homeClassName));
    /* how to do next?
    }

    I am not sure what you are trying to do. But at some point you should know which methods to call on the remote interfaces. Maybe the method names are stored in the XML file as well or you have a set of standard method names (also consider parameters).
    However, this can be solved by reflection. Look at the java.lang.reflect package, especially java.lang.reflect.Method, and also at java.lang.Class.
    If you are doing this on the app server:
    I've seen posts where people say that reflection is not permitted in EJB, but I don't think so. Check the EJB spec.
    If you are doing this in an application: reflection is always permitted. Probably also in applets and JSP.

  • How do I return two values from a stored procedure into an "Execute SQL Task" within SQL Server 2008 R2

    Hi,
    How do I return two values from a
    stored procedure into an "Execute SQL Task" please? Each of these two values need to be populated into an SSIS variable for later processing, e.g. StartDate and EndDate.
    Thinking about stored procedure output parameters for example. Is there anything special I need to bear in mind to ensure that the SSIS variables are populated with the updated stored procedure output parameter values?
    Something like ?
    CREATE PROCEDURE [etl].[ConvertPeriodToStartAndEndDate]
    @intPeriod INT,
    @strPeriod_Length NVARCHAR(1),
    @dtStart NVARCHAR(8) OUTPUT,
    @dtEnd NVARCHAR(8) OUTPUT
    AS
    then within the SSIS component; -
    Kind Regards,
    Kieran. 
    Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/

    Below execute statement should work along the parameter mapping which you have provided. Also try specifying the parameter size property as default.
    Exec [etl].[ConvertPeriodToStartAndEndDate] ?,?,? output, ? output
    Add a script task to check ssis variables values using,
    Msgbox(Dts.Variables("User::strExtractStartDate").Value)
    Do not forget to add the property "readOnlyVariables" as strExtractStartDate variable to check for only one variable.
    Regards, RSingh

  • How to read appended objects from file with ObjectInputStream?

    Hi to everyone. I'm new to Java so my question may look really stupid to most of you but I couldn't fined a solution by myself... I wanted to make an application, something like address book that is storing information about different people. So I decided to make a class that will hold the information for each person (for example: nickname, name, e-mail, web address and so on), then using the ObjectOutputStream the information will be save to a file. If I want to add a new record for a new person I'll simply append it to the already existing file. So far so good but soon I discovered that I can not read the appended objects using ObjectInputStream.
    What I mean is that if I create new file and then in one session save several objects to it using ObjectOutputStream they all will be read with no problem by ObjectInputStream. But after that if in a new session I append new objects they won't be read. The ObjectInputStream will read the objects from the first session after that IOException will be generated and the reading will stop just before the appended objects from the second session.
    The following is just a simple test it's not actual code from the program I was talking about. Instead of objects containing different kind of information I'm using only strings here. To use the program use as arguments in the console "w" to create new file followed by the file name and the strings you want save to the file (as objects). Example: "+w TestFile.obj Thats Just A Test+". Then to read it use "r" (for reading), followed by the file name. Example "+r TestFile.obj+". As a result you'll see that all the strings that are saved in the file can be successfully read back. Then do the same: "+w TestFile.obj Thats Second Test+" and then read again "+r TestFile.obj+". What will happen is that the strings only from the first sessions will be read and the ones from the second session will not.
    I am sorry for making this that long but I couldn't explain it more simple. If someone can give me a solution I'll be happy to hear it! ^.^ I'll also be glad if someone propose different approach of the problem! Here is the code:
    import java.io.*;
    class Fio
         public static void main(String[] args)
              try
                   if (args[0].equals("w"))
                        FileOutputStream fos = new FileOutputStream(args[1], true);
                        ObjectOutputStream oos = new ObjectOutputStream(fos);
                        for (int i = 2; i < args.length ; i++)
                             oos.writeObject(args);
                        fos.close();
                   else if (args[0].equals("r"))
                        FileInputStream fis = new FileInputStream(args[1]);
                        ObjectInputStream ois = new ObjectInputStream(fis);
                        for (int i = 0; i < fis.available(); i++)
                             System.out.println((String)ois.readObject());
                        fis.close();
                   else
                        System.out.println("Wrong args!");
              catch (IndexOutOfBoundsException exc)
                   System.out.println("You must use \"w\" or \"r\" followed by the file name as args!");
              catch (IOException exc)
                   System.out.println("I/O exception appeard!");
              catch (ClassNotFoundException exc)
                   System.out.println("Can not find the needed class");

    How to read appended objects from file with ObjectInputStream? The short answer is you can't.
    The long answer is you can if you put some work into it. The general outline would be to create a file with a format that will allow the storage of multiple streams within it. If you use a RandomAccessFile, you can create a header containing the length. If you use streams, you'll have to use a block protocol. The reason for this is that I don't think ObjectInputStream is guaranteed to read the same number of bytes ObjectOutputStream writes to it (e.g., it could skip ending padding or such).
    Next, you'll need to create an object that can return more InputStream objects, one per stream written to the file.
    Not trivial, but that's how you'd do it.

  • Returning a table from a stored procedure

    hi, i need to return a table from a stored procedure and show it, and come to this, but a don't know hoy to run it, so i don't know if it is right, can anyone help me?
    uTable out objects_uptime%rowtype
    as
    begin
    select * into uTable from objects_uptime;
    end;

    well, i finally discovered how to do the trick
    this is the code for the function:
    CREATE OR REPLACE FUNCTION FN_GET_RECORDS RETURN UPTIME PIPELINED IS
    CURSOR cUptime is select * from objects_uptime;
    p refcur.refcur_t;
    temp p%ROWTYPE;
    temp2 OUPTIME := OUPTIME(null, null, null, null, null, null, null, null, null);
    BEGIN
    OPEN cUptime;
    LOOP
    FETCH cUptime into temp;
    temp2.OBJ_NAME := temp.OBJ_NAME;
    temp2.IP := temp.IP;
    temp2.STATUS := temp.STATUS;
    temp2.DOE := temp.DOE;
    temp2.ENABLED := temp.ENABLED;
    temp2.COMMENT00000 := temp.COMMENT00000;
    temp2.USERID := temp.USERID;
    temp2.OBJECTID := temp.OBJECTID;
    temp2.MNTID := temp.MNTID;
    pipe row(temp2);
    EXIT WHEN cUptime%NOTFOUND;
    END LOOP;
    RETURN;
    END FN_GET_RECORDS;
    and this for the auxiliar package, object and table:
    CREATE OR REPLACE PACKAGE REFCUR
    as
    TYPE refcur_t IS REF CURSOR RETURN objects_uptime%ROWTYPE;
    end REFCUR;
    CREATE OR REPLACE TYPE OUPTIME AS OBJECT ( "OBJ_NAME"
    VARCHAR2(255), "IP" VARCHAR2(20), "STATUS" VARCHAR2(10),
    "DOE" DATE, "ENABLED" NUMBER(10, 1), "COMMENT00000"
    VARCHAR2(1000), "USERID" VARCHAR2(50), "OBJECTID" NUMBER(10,
    1), "MNTID" NUMBER(10, 1) )
    CREATE TYPE TUPTIME AS
    TABLE OF OUPTIME
    i call it this way:
    select * from table(FN_GET_RECORDS ())
    if anyone knows how to do the same in a shorter manner, tell me please.
    thanks to everybody for the help.

  • Read item from Java class and call to stored function/procedure of database

    Hi,
    I am looking solution that I was trying to find becasue of I am not expert and novice of ADF so I am getting problem to do. I am trying migrating from oracle forms to JDeveloper[ADF].
    I want to call database stored function from JSF pages by java bean class of a button press event (manually created) and after button event I have called java class which I created manually. But I can not read that values what I given into jsp page.
    question1: How can I read jsp pages items value to java class ?
    question2: How can I call to database stored function/procedure with that parameter?
    question3: How can I use return value of that stored function/procedure ?
    Please reply me .
    Thanks,
    zakir
    ===
    Edited by: Zakir Hossain on Mar 29, 2009 10:22 AM

    ---

  • Nwdi-managed access of pcd-objects from java web dynpro

    Hi,
    im am trying to access portal pcd-objects from a java web dynpro component (namely getting and setting personalized iview properties). for locally managed web dynpro components this works fine with the code below.
    when i try the same with a nwdi managed web dynpro component i run into problems regarding references to used dcs. for instance, i need to reference used dc SAP_JTECHS/tc/epbc/pcm/adminapi/java because the build needs tcepbcpcmadminapijava.jar which is inside the mentioned dc. but access permissions of this dc don't allow the dependency. when i try to "add used dc ..." in nwds i get the error message: illegal dependency: access list does not allow use of ...
    has someone any solution for this problem? are there other ways of accessing pcd-objects from java web dynpro (nwdi managed!)?
    thanks
    heiko
    private static void savePersonalizationData(String value) {
         try {
              IAttributeSet attributeSet = (IAttributeSet) getIview(IVIEW);
              attributeSet.putAttribute(ATTRIBUTE, value);
              attributeSet.save();
         } catch (Exception e) {
    private static Object getIview(String pcdPath) throws Exception {
         Hashtable env = new Hashtable();
         env.put(
              com.sap.portal.directory.Constants.REQUESTED_ASPECT,
              com.sap.portal.pcm.admin.PcmConstants.ASPECT_SEMANTICS);
         env.put(
              Context.SECURITY_PRINCIPAL,
              WDClientUser.getCurrentUser().getSAPUser());
         env.put(
              IPcdContext.PCD_PERSONALIZATION_PRINCIPAL,
              WDClientUser.getCurrentUser().getSAPUser());
         InitialContext iCtx = new InitialContext(env);
         return iCtx.lookup(pcdPath);

    Hi Kust,
    To access the PCD objects the code you used looks ok for me but your main issues is related to the dc access permissions. This thread discussed about the similar issue. Please review this below thread.
    /message/979328#979328 [original link is broken]
    Regards
    Krishna Reddy

Maybe you are looking for

  • Is it possible to only allow given MAC addresses to access ActiveSync in Exchange 2013?

    We are designing a new Exchange 2013 environment for a client and one of their requests was to only allow known mobile devices to access ActiveSync. I can see that you can allow or block remote devices based on IP Address, model, etc. but we'd need t

  • How to do a restore that saves my files and photos on a k330 thinkcente​r win 8.1

    The computer came with windows home premium I upgraded it to windows 78 then windows 8.1 When I tried to restore it it asks for a source disk I offerred it the lenovo windows 7 drivers pac v2.5 and the windows 8 discs both are 64 bit by the way ..no

  • Event loop hang, Windows Forms

    My C# console application acquires video frames from a camera and uses OpenCV for per-frame processing.  The program is mostly an infinite loop with busy-wait on frame acquisition at the start of the loop and a sleep at the end of the loop as recomme

  • Workforce Planning for Partially Confirmed Activities

    Hi All, I have recently configured Workforce planning for one of the clients, and it has been working as per the requirement. Here, I have configured Workforce Planning profile and Scheduling parameters of Network. So, once a Project and a Network is

  • Oracle Application Server 10.1.3 on WinXP (x64)

    Hello, i would like to know, if there is a 64bit-Version of Oracle Application Server 10.1.3 available which can be installed on Windows XP (x64) or if at last a release date for such version exists. kind regards chris