Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Location
    US
    Posts
    314

    Arrow Unanswered: Java Stored Procedures

    Hi
    I am trying to learn how to use Java Stored Procedures.
    I would appreciate if someone could take out sometime, and help with the same. I read the document concerning the Java Stored Procedures.

    The only thing that stops me from starting on this is one running example.
    I would like someone to help me write a simple Java Stored Procedure, writing the spec.

    The following example would suffice.
    The function would return the SYSDATE, like return SYSDATE;

    The procedure could then be called to initialize a date object, like dt_ship from TABLE1.
    like update TABLE1 set dt_ship="function()" where id=xyzzz.

    Waiting for a response which specifies how to write the code, the call spec, how to register the function with oracle, and how to call.
    Thanx and Regards
    Aruneesh

  2. #2
    Join Date
    Jul 2003
    Posts
    6

    Re: Java Stored Procedures

    hi

    CallableStatement call = conn.prepareCall{
    "{call procedurename(?, ?, ?)}"};


    note:
    procedurename is the name of the procedure

    ? stands for the input parameters

  3. #3
    Join Date
    Jul 2003
    Location
    Brazil, Sao Paulo - SP
    Posts
    4

    Re: Java Stored Procedures

    Hi.

    The first thing to do is to create a class that implements a static method that you need, For instance:

    public class ReturnDate {
    public static jata.util.Date getDate() {
    return new Date();
    }
    }

    Then, you need to compile this class

    javac ReturnDate

    Then you have to load this class into your database using loadjava Oracle application. If your using a IDE like JDev, all you need to do is to create a new JavaStoredProcedure Deployment profile and configure it in a easy way.

    loadjava -u scott/tiger@dbhost:1521rcl -t -r ReturnDate.class

    Then, you need to bind the procedure to that java class.

    CREATE OR REPLACE FUNCTION get_date RETURN NUMBER
    AS LANGUAGE JAVA NAME 'ReturnDate.getDate() return java.util.Date';

    Done, you've created your java stored procedure.
    (To load a class into Oracle, you need first to hava oracle set to run java applications, I mean, you should have first installed aurora jvm with oracle, during installation process)

    Regards,

    Originally posted by aruneeshsalhotr
    Hi
    I am trying to learn how to use Java Stored Procedures.
    I would appreciate if someone could take out sometime, and help with the same. I read the document concerning the Java Stored Procedures.

    The only thing that stops me from starting on this is one running example.
    I would like someone to help me write a simple Java Stored Procedure, writing the spec.

    The following example would suffice.
    The function would return the SYSDATE, like return SYSDATE;

    The procedure could then be called to initialize a date object, like dt_ship from TABLE1.
    like update TABLE1 set dt_ship="function()" where id=xyzzz.

    Waiting for a response which specifies how to write the code, the call spec, how to register the function with oracle, and how to call.
    Thanx and Regards
    Aruneesh

  4. #4
    Join Date
    Jul 2003
    Location
    US
    Posts
    314

    Arrow Thanx

    Hi
    I am able to write the class files and figured out a good knowledge on how to load classes in JVM.

    The only thing stopping me from testing the same, is the fact the JVM is not activated on the Oracle Server I am using.

    Probably it would a day or two that I start using it.

    Thanx and Regards
    Aruneesh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •