Call java method from pl/sql

Hello,
i have library written in java and i need call one method from this lib in pl/sql. it's returning string. Is it possible? If, yes can you direct me to some docs about this topic? We have oracle version 8 and 10.
Thanks a lot.

i think java support was added to oracle from 8i. is you package is in the form of jar file or java code.?
you can you jdeveloper the best one i found for writing java and sqlj stored procedures
you can use loadjava here is a cut and paste from a example i have on my system
REM Server-side translation, execution of SQLJ program
REM
REM Environment setup:
REM - have sqlj and javac in your PATH
REM - SQLJ libaries in your CLASSPATH
REM
REM In the directory having the SQLJ demo for the server,
REM execute the following commands
REM Drop any previously-loaded demo classes
sqlplus scott/tiger @Dropl
REM Load the SQLJ source directly
call loadjava -oci8 -resolve -force -user scott/tiger ServerDemo.sqlj
REM Publish SQL wrapper and run the demo on the server using SQL*Plus
sqlplus scott/tiger @Run.sql
REM In sqlplus, it should print
REM Hello! I'm SQLJ in server!
REM Today is <date>

Similar Messages

  • Calling Java Methods from Stored Procedures

    Can I call Java Methods from Oracle Stored Procedures? I have a Java framework that logs events and would like to reuse it for logging events that occur in stored procedures.
    null

    You need to publish java class methods to plsql.
    Attached below is some information.
    Although both PL/SQL modules and Java classes are stored in the database
    and are managed by many of the same mechanisms, each of them resides in
    its own namespace. Therefore, Java methods are not accessible from SQL
    and PL/SQL by default. In order to expose Java methods to the SQL and
    PL/SQL engines, first publish that Java method to the SQL namespace using
    a 'Call Spec'.
    Note: A 'Call Spec' does not create an additional layer of
    execution so there is no performance penalty incurred.
    A 'Call Spec' is simply a syntactical mechanism used to
    make a method known in the SQL namespace.
    The SQL name established by the 'Call Spec' can be top-level or packaged.
    The syntax differs only slightly and is consistent with that used for
    PL/SQL procedures and packages. For more information on the exact
    syntax, see the references listed in 'Related Topics'.
    In general, a top-level procedure 'Call Spec' takes the form:
    CREATE OR REPLACE PROCEDURE procname ( pname mode ptype, ... )
    AS LANGUAGE JAVA NAME 'javaname ( javatype, ... )';
    Where: procname is the SQL name you wish to publish
    pname is the name for a parameter to procname
    mode is the parameter mode (i.e. IN, OUT, IN OUT)
    ptype is a valid SQL type (e.g. NUMBER, CHAR, etc.)
    javaname is the fully qualified name of the Java method
    javatype is a Java type for the corresponding parameter
    Likewise, a top-level function 'Call Spec' takes the form:
    CREATE OR REPLACE FUNCTION fname ( pname mode ptype, ... ) RETURN rtype
    AS LANGUAGE JAVA NAME 'javaname ( javatype, ... ) return javatype';
    Where: fname is the SQL name you wish to publish
    rtype is the SQL return type of the function
    Note: Within the NAME clause, everything within quotes is case
    sensitive. For example, if the keyword 'return' is in all
    CAPS, this Call Spec will not compile.
    Other optional parts of this syntax have been omitted here for simplicity.
    Additional examples in subsequent sections illustrate some of these options.
    eg
    CREATE PROCEDURE MyProc (rowcnt IN NUMBER, numrows OUT NUMBER)
    AS LANGUAGE JAVA NAME 'MyClass.MyMethod(int, int[])';
    There are several important things to note here:
    1.) The 'Call Spec' for a JSP must be created in the same schema as the
    corresponding Java class that implements that method.
    2.) IN parameters are passed by value. This is the only parameter mode
    available in Java. OUT parameters, therefore, must be passed as single
    element arrays in order to emulate pass by reference.
    3.) Parameter names do not need to match, but the number and types of
    the parameters must match (with just one exception - see item 5 below).
    Oracle 8i supports conversions between an assortment of SQL and Java.
    See the references listed in 'Related Topics' for additional information.
    4.) Primitive types (e.g. int, float, etc.) are not required to be fully
    qualified with any package name. However, standard Java object types
    (e.g. String, Integer, etc.) as well as any user defined object types
    (e.g. like those generated by JPublisher) must be prefixed with a
    corresponding package name (e.g. java.lang) if applicable.
    5.) The 'main' method which takes a single String[] parameter can be
    mapped to any PL/SQL procedure or function which takes some number
    of VARCHAR2 or CHAR type IN parameters. For example, the java method:
    public static void main ( String[] args ) { ... }
    can be mapped to each of the following:
    PROCEDURE MyProc2 ( arg1 IN CHAR ) ...
    PROCEDURE MyProc3 ( arg1 IN CHAR, arg2 IN VARCHAR2 ) ...
    PROCEDURE MyProc4 ( arg1 IN VARCHAR2, arg2 IN VARCHAR2 ) ...
    and so forth. Parameters map to the corresponding element of the String
    array (e.g. arg1 -> args[0], arg2 -> args[1], etc.).
    null

  • How to call Java method from XSLT??

    Hi All,
    Jdev 11.1.1.3.0
    I have a requirement to implement that, I have to call Java method from XSLT. Could anyone please suggest to implement that??
    Thanks,
    Santosh M E

    As pointed by others, you must expose your method as a custom function, registering with JDeveloper (for development time) as well as with SOA Suite (for runtime).
    In the link below you will find a simple step by step example:
    https://blogs.oracle.com/reynolds/entry/building_your_own_path
    Regards,
    Luis F. Heckler

  • How to call java method from workflow script?

    Hi
    I have a requirement of updating field value 'Document Status' based on review/approve of content from Workflow and hence need to update the version number. For that I need to call my java method from workflow during submit of review/approve condition. Please let me know how to call java method from workflow?
    Is there any alternative better way to achive this requirement from workflow? Please suggest.
    Thanks,
    Sarang

    OK. So, I think we can all conclude that you don't need to call any Java method, can't we? And, that wfUpdateMetadata is the command that will update your metadata.
    Now, the question is what are its arguments. It has two - the first is the name of a custom metadata field to be updated (let's suppose that one field is called xMinorVersion, and the other xMajorVersion), the other is the new value, e.g. <$wfUpdateMetaData("xMinorVersion", "New value.")$>As for new value - do you insist on using strings? Since you want to increase the value, it would be more convenient to work with numbers. For instance, with integers you could go with <$wfUpdateMetaData("xMinorVersion", xMinorVersion + 1)$>With strings you will need to convert it to numbers and back to strings. Besides, what happens if you have more than 100 minor versions? (you mentioned you want to add 0.01, but that would finally increase the major version, wouldn't it?) So, I think these two numbers are independent (perhaps, with exception that increase on the major version set the minor version to .00).
    If you want to present it, you can use profiles that will construct for you the representation 2.304 out of MajorVersion = 2, MinorVersion = 304
    Solved?

  • How to call java method from C ?

    Hello,
    I try to call a native method from java which calls java method from the same class. Exception (noSuchMethodError) is thrown. Any ideas?
    Thanx in advance !
    here is the source of the native method :
    JNIEXPORT jint JNICALL Java_TestDll_Proc_1Mul_1Int_1Var_1Var_1Stdcall (JNIEnv * env, jclass jcl, jint jarg1, jint jarg2) {
    int arg1;
    int arg2;
    int arg3;
    jint res;
    char * ch = "test";
    jfieldID fid;
    jmethodID mid;
    int (* procedure) (int *, int * ,int *);
    int mch;
    arg1 = (int )jarg1;
    arg2 = (int )jarg2;
    procedure = GetProcAddress(libraryHandle,"Proc_Mul_Int_Var_Var_Stdcall");
    procedure(&arg1,&arg2,&arg3);
    res = (jint) arg3;
    printf("(*env)->GetMethodID(env, jcl, \"test\", \"()V\");\n");
    mid = (*env)->GetMethodID(env, jcl, "test", "()V");
    printf("(*env)->CallVoidMethod(env, jcl, mid);\n");
    (*env)->CallVoidMethod(env, jcl, mid);
    return res;
    here is the source of the java file:
    public class TestDll {
    static {
    System.loadLibrary("testdllwrap");
    System.out.println("java: Library testdllwrap.dll loaded");
    public TestDll() {
    public native int Proc_Mul_Int_Var_Var_Stdcall(int jarg1, int jarg2);
    public void test() {
    System.out.println("java: test()");
    public static void main(String[] args) {
    TestDll access = new TestDll();
    int a = 5;
    int b = 6;
    int c = 0;
    System.out.println("Calling Proc_Mul_Int_Var_Var_Stdcall");
    c = access.Proc_Mul_Int_Var_Var_Stdcall(a,b);
    System.out.println("Java Result = " + c);

    Something is wrong with the code you posted here.
    Since your native method is not static, it should have the jobject instance as a parameter in the function prototype, not a jclass. Also, you should be calling CallObjectMethod with a jobject, not jclass.
    Check out Jace at http://jace.reyelts.com/jace.
    To call the java method you would do:
    JNIEXPORT jint JNICALL Java_TestDll_Proc_1Mul_1Int_1Var_1Var_1Stdcall
    (JNIEnv * env, jobject jTestDll, jint jarg1, jint jarg2) {
      TestDll testDll( jTestDll );
      testDll.test();
    }God bless,
    -Toby Reyelts

  • Call Java Method From JavaScript Function

    hi everyone
    i need a help in calling Java method from a javaScript method
    ex:
    function confirmAddRecord() {
    cHours =document.getElementById('frmP:ChargeHours').value;
    cSTime =document.getElementById('frmP:ChargeStartTime').value;
    var answer = confirm("Are you sure you want to add Record?")
    if (answer){
    here i want to call the Java Method that is located in session bean that takes the upper params cHours & cSTime
    else{
    return false;
    i know i can do it as an action button but it is required me to be in that way can any one help plz
    Message was edited by:
    casper77

    That depends on the nature of your parameters. I guess you calculate the params on client and then want to submit them. In this case and if you don't want to use Ajax simple add some <input type="hidden"> elements (of course there correspondend components dependent of your framework) and store the params there. If the javascript isn't invoked by a button click, you can use a button nevertheless. Set visible="false" and call
    document.getElementById('client_id_of_my_hidden_button').click();
    (or maybe doClick() dependent on your framework).

  • Calling Java methods from C program

    After a year or so using these excellent forums to answer my queries, without ever having to post a question, I've finally had to ask for help with this one. I've already looked through the JNI tutorial, and these forums, extensively, but I'm still not quite sure of how best to solve my problem.
    I need to call Java methods from a C program. I've already used JNI to call a simple C program from Java, and that's fine, but I just can't determine exactly what I need to do for the reverse to work.
    What is the definitive solution for calling Java from C? Is it to use the invocation APIs to create a JVM, and then access it through the various GetMethod, FindClass methods? Or can I 'reverse engineer' the process I followed to get Java to call C?? The tutorial is a bit confusing, as the example it gives uses Callback stuff, but I guess that's only useful when you want to go Java-C-Java??
    Advice appreciated,
    Rich

    Forgive my blatant bumping, but anyone, please?

  • Calling Java Methods from C++

    Hi ppl,
    I'm a real java newbie but I'm working on a task which requires me to call java methods from a C++ program. Does anyone have any code snippet for me to start of on, say, a c++ prgram which calls a java method that prints "Hello World :oD " to the screen? Many thanks.
    Tyler

    1. Have you looked at the tutorial?
    (Look elsewhere on this website.)
    2. Have you considered buying a book?
    (Try "essential JNI", by Rob Gordon.)

  • Call Java Method from BPM Process

    Hi,
      I have defined a java class with set of methods , and I want to know if there is any way to call those methods from a BPM process..
    Thanks in Advance,,
    Best Regards,,
    Ola Essa..

    Use the spring component context in soa suite instead of ejb. Look for documentation in soa suite developer guide. Only if you have existing ejbs then use ejb adapters.
    See this http://www.oracle.com/technetwork/middleware/soasuite/learnmore/fivecoolusecasesforspring-1885529.pdf
    Vikram
    Message was edited by: VikramFusionApplied

  • How to call java method from actionscript

    I've just now started working on Flex. May be its basic question but I’m not aware of it – how can I call a java method from actionscript. I want to call some java method on double click of a event. Can you please let me know how to proceed on this?

    OK. So, I think we can all conclude that you don't need to call any Java method, can't we? And, that wfUpdateMetadata is the command that will update your metadata.
    Now, the question is what are its arguments. It has two - the first is the name of a custom metadata field to be updated (let's suppose that one field is called xMinorVersion, and the other xMajorVersion), the other is the new value, e.g. <$wfUpdateMetaData("xMinorVersion", "New value.")$>As for new value - do you insist on using strings? Since you want to increase the value, it would be more convenient to work with numbers. For instance, with integers you could go with <$wfUpdateMetaData("xMinorVersion", xMinorVersion + 1)$>With strings you will need to convert it to numbers and back to strings. Besides, what happens if you have more than 100 minor versions? (you mentioned you want to add 0.01, but that would finally increase the major version, wouldn't it?) So, I think these two numbers are independent (perhaps, with exception that increase on the major version set the minor version to .00).
    If you want to present it, you can use profiles that will construct for you the representation 2.304 out of MajorVersion = 2, MinorVersion = 304
    Solved?

  • How to call Java methods from a Windows application?

    Hello all,
    At our company, we need to integrate our product which is a Java Swing application with a Windows application. Specifically, we are trying to call Java methods that reside in our application from the Lotus Notes email client application, which is a native Windows application. Such that when a user clicks a button in the Lotus Notes email client, it will trigger an event in our Swing application. Is this possible using JNI? Do you know of any resources or references relating to this kind of a project?
    Thanks,
    Mete Kural

    If there is some dll interface that lets Lotus Notes load up and use a DLL, then yes, this should be possible.

  • How to call java method from xsl

    hi friends,
    How to call a java method from xsl, i have a xsl file which will call the java method and retrieve the value and display it to the user. but its work well when i set xalan.jar and xerces.jar and the java class files in my classpath and run as
    java org.apache.xalan.xslt.Process -in navigate.xml -xsl nav-exst.xsl -HTML -out navoutpage.html[b]
    in the command prompt but when i deploy it as web application it gives error as
    [b]Namespace 'MyPack' does not contain any functions[b]

    OK. So, I think we can all conclude that you don't need to call any Java method, can't we? And, that wfUpdateMetadata is the command that will update your metadata.
    Now, the question is what are its arguments. It has two - the first is the name of a custom metadata field to be updated (let's suppose that one field is called xMinorVersion, and the other xMajorVersion), the other is the new value, e.g. <$wfUpdateMetaData("xMinorVersion", "New value.")$>As for new value - do you insist on using strings? Since you want to increase the value, it would be more convenient to work with numbers. For instance, with integers you could go with <$wfUpdateMetaData("xMinorVersion", xMinorVersion + 1)$>With strings you will need to convert it to numbers and back to strings. Besides, what happens if you have more than 100 minor versions? (you mentioned you want to add 0.01, but that would finally increase the major version, wouldn't it?) So, I think these two numbers are independent (perhaps, with exception that increase on the major version set the minor version to .00).
    If you want to present it, you can use profiles that will construct for you the representation 2.304 out of MajorVersion = 2, MinorVersion = 304
    Solved?

  • How to call  Java method from SAPUI5 applications?

    Hi Experts,
        Please give me information that how can I call Java method or jars from SAPUI5 applications?
    Thanks,
    Nag

    Hello Nag,
    why do open this thread in BRM Space? I would suggest reopen this in "UI Development Toolkit for HTML5 Developer Center" Space.
    Regards,
    Tobias

  • Problem calling java method from c

    Hi ,
    I'm trying to call a java method from a C program. it gives no error during compilation as well as building the application. but when i tried to create the JVM by running my application it pops up the message "The application failed to start because jvm.dll was not found. Re-installing the application may fix the problem." I tried out setting all the environment variables to include the jvm.dll(PATH set to c:\j2sdk1.4.2_05\bin;c:\j2sdk1.4.2_05\jre\bin). Still got the same message. Then i re-installed java platform once more. Even now i get the same error. I have more than one jvm.dll at locations jre\bin\client and server, oracle has some jvm.dll . Will that be a problem? if so can i remove those? which of them should be removed and how?
    The code i'm using is
    #include <stdio.h>
    #include <jni.h>
    #include <windows.h>
    //#pragma comment (lib,"C:\\j2sdk1.4.2_05\\lib\\jvm.lib")
    JavaVM jvm; / Pointer to a Java VM */
    JNIEnv env; / Pointer to native method interface */
    JDK1_1InitArgs vm_args; /* JDK 1.1 VM initialization requirements */
    int verbose = 1; /* Debugging flag */
    FARPROC JNU_FindCreateJavaVM(char *vmlibpath)
    HINSTANCE hVM = LoadLibrary("jre\\bin\\server\\jvm.dll");
    if (hVM == NULL)
    return NULL;
    return GetProcAddress(hVM, "JNI_CreateJavaVM");
    void main(int argc, char **argv )
    JavaVM jvm = (JavaVM )0;
    JNIEnv env = (JNIEnv )0;
    JavaVMInitArgs vm_args;
    jclass cls;
    jmethodID mid;
    jint res;
    FARPROC pfnCreateVM;
    JavaVMOption options[4];
    // jint (__stdcall pfnCreateVM)(JavaVM *pvm, void **penv, void *args) = NULL;
    options[0].optionString = "-Djava.compiler=NONE"; /* disable JIT */
    options[1].optionString = "-Djava.class.path=c:/j2sdk1.4.2_05/jre/lib/rt.jar"; /* user classes */
    options[2].optionString = "-Djava.library.path=lib"; /* set native library path */
    options[3].optionString = "-verbose:jni"; /* print JNI-related messages */
    /* Setup the environment */
    vm_args.version = JNI_VERSION_1_4;
    vm_args.options = options;
    vm_args.nOptions = 4;
    vm_args.ignoreUnrecognized = 1;
    JNI_GetDefaultJavaVMInitArgs ( &vm_args );
    pfnCreateVM = JNU_FindCreateJavaVM("jre\\bin\\server\\jvm.dll");
    res = (*pfnCreateVM)(&jvm,(void **) &env, &vm_args );
    // res = JNI_CreateJavaVM(&jvm,(void **) &env, &vm_args );
    /* Find the class we want to load */
    cls = (*env)->FindClass( env, "InstantiatedFromC" );
    if ( verbose )
    printf ( "Class: %x" , cls );
    /*jvm->DestroyJavaVM( );*/
    Could anyone help me solve this problem as early as possible, bcoz i'm in an urge to complete the project.
    Thanks in advance.
    Usha.

    You either have to add to the system path of where is your jvm.dll is located or explicitly link to jvm.dll call GetProcAddress to obtain the address of an exported function in the DLL.

  • Call Java Method From C#

    I have a complete Java Classes solution working perfectly and i would like to "re-use" it from my new main C# program. Actually, i don't know which process could authorize to invoke Java method from C# method.
    Can anybody help me ?
    Thanks in advance for your assistance.

    If you want a very heavy and inefficient solution you can try this:
    - Make your java classes "web services" - it usually requires setting up a web container like Tomcat
    - Call the web services in your C# program.
    Sometimes my solution could work (for instance, if your Java classes can't be rewritten in C# in a short time, and if they are infrequently called, and if they do a lot of work inside, and if you already has a web container properly set up in your environment).

Maybe you are looking for

  • Ipod touch will no longer sync my songs, they show up for a few seconds then disappear help

    for some reason when I try to sync my songs to my ipod touch, they will all show up briefly, then disappear once I hit the sync button?  very frustrating, have never had this problem in the past, any suggestions would be great

  • My iphone 3g has a constant bright light

    My iphone has a constant bright light. To get rid of it i have to reset but once i lock the screen the bright light returns. Any advice on how to fix this.

  • Adding a hidden column in the report

    i have to add a column to the existing form,the newly added column should not visible at the run time .whenever i am inserting the data into the form automaticallly the newly added column should update with the flag as 'N'. Note:i will not enter any

  • SORTING FOR THE CALCULATION FIELD IN CROSS TAB REPORT

    LIST_G_AUCTION_TITLE> <G_AUCTION_TITLE> <BID_NUMBER>5002</BID_NUMBER> <AUCTION_TITLE>E2E-01 Construction RFQ</AUCTION_TITLE> <ITEM_NUMBER>C2631</ITEM_NUMBER> <ITEM_DESCRIPTION>4G000,000,0STRUC,X,SPECIAL STRUCTURE</ITEM_DESCRIPTION> <ESTIMATED_QTY>1</

  • ORA-28579 when invoking an R script via rqTableEval

    Hi, I'm working with OBIEE SampleApp 406 virtual image. I managed to get almost everything to work there ... almost. Right now I'm trying to figure out why I'm getting ORA-28579 only in a very small number of occasions. For example: select id, image