How to call a java method in a Stored procedure

Hi.,
I was trying to call a method in a stored procedure
This was my procedure
CREATE OR REPLACE PROCEDURE proc_copy_file(sr_file VARCHAR2,dt_file VARCHAR2)
AS LANGUAGE JAVA
NAME 'FileCopy.copyfile(String,String)'; // calling a java method
/   this was my java method
CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "FileCopy" as
import java.io.File;
  import java.io.IOException;
  import java.io.FileReader;
  import java.io.FileWriter;
  import javax.imageio.stream.FileImageInputStream;
  import javax.imageio.stream.FileImageOutputStream;
  import java.security.AccessControlException;
  public class FileCopy {
      // Define variable(s).
          private static int c;
          private static File file1,file2;
          private static FileReader inTextFile;
          private static FileWriter outTextFile;
          private static FileImageInputStream inImageFile;
          private static FileImageOutputStream outImageFile;
          // Define copyText() method.
          public static void copyfile(String fromFile,String toFile) throws AccessControlException
            // Create files from canonical file names.
            file1 = new File(fromFile);
            file2 = new File(toFile);
            // Copy file(s).
            try
              // Define and initialize FileReader(s).
              inTextFile  = new FileReader(file1);
              outTextFile = new FileWriter(file2);
              // Read character-by-character.
              while ((c = inTextFile.read()) != -1) {
                outTextFile.write(c); }
              // Close Stream(s).
              inTextFile.close();
              outTextFile.close(); }
            catch (IOException e) {
              System.out.println ("-------"); }
         // return 1;
      public static void main(String[] args){
                      switch(args.length){
                              case 0: System.out.println("File has not mentioned.");
                                              System.exit(0);
                              case 1: System.out.println("Destination file has not mentioned.");
                                              System.exit(0);
                              case 2: copyfile(args[0],args[1]);
                                              System.exit(0);
                              default : System.out.println("Multiple files are not allow.");
                                                System.exit(0);
};while i am executing this method i m getting error as
ORA-29531: NO METHOD COPYFILE IN CLASS FILECOPY
ORA-06512: AT "RMVER721.PROC_COPY_FILE", LINE 1could anyone help me

Looks like it is a matter of not quite the same namespace for String object.
I can get it to work by the java source containing:
          public static void copyfile(java.lang.String fromFile,java.lang.String toFile) throws AccessControlExceptionAnd the PL/SQL source:
NAME 'FileCopy.copyfile(java.lang.String,java.lang.String)'; // calling a java methodSeems like when you just use "String", then the namespace resolving in the java source is not the same as the namespace resolving in the PL/SQL?
Addendum:
You do not need to put java.lang.String in the java source, String will do (java.lang is by default "imported"?)
But in the PL/SQL source java.lang namespace prefix is needed - java.lang is not "imported" here.
Edited by: Kim Berg Hansen on Nov 23, 2011 1:07 PM

Similar Messages

  • Is there a tutorial on - how to call static java methods

    I have defined external JAVA resource using a .jar file and have successfully catalogged the same. Now I need to pass variables to a static method in a class and also get the return variable mapped into a BPM variable.
    Can someone share sample Java Invokation code, how to call methods in a class, how to instantiate a singleton or reference an existing instance of singleton class.
    Any sample code or sample projects will be useful.
    Also can I se ethe java system.out.println output in BPM Logviewer
    Arvind

    Hi Arvind,
    Sure you've done this, but the first step is to catalog the Jar file. Before an Oracle BPM project can use the Java component, the appropriate Java JAR files must be added to the project.
    Add the Jar File(s) to the External Resources:
    1. Right-click the External Resources item in the Project Navigator tab
    2. From the pop-up menu, select New External Resource.
    3. Name this new Java resource "MyNewJavaComponents" and ensure its type is Java Class Library.
    4. Add the Java jar file(s)
    Catalog and Expose the Java Components:
    5. Add a new module in the Catalog called "IntegrationComponents".
    6. Generate a Java integration component by right-clicking the IntegrationComponents module and select "Catalogue Component" -> "Java".
    7. Using the Java configuration you just created called MyNewJavaComponents, click the Next button to automatically introspect the Java libraries.
    8. Select the class where your method(s) are located and click the Next -> Finish buttons to have Oracle BPM generate the integration component for you.
    9. If you expand the newly exposed Java component, you can see a method has been created for each public method (attributes would also be automatically created if this class had any public attributes). If you've included the appropriate BeanInfo class in the JAR, you'll note that the method parameters are appropriately named.
    How to Invoke Public Java methods Exposed in the Catalog:
    10. Open the method editor for an automatic activity in the process (or any BPM Object method with its "Server Side" property set to "Yes").
    11. Drag one of the Java methods you just exposed inside your IntegrationComponents module into the automatic activity's method. Once you drag it in, here's what you might see if you're using the Java syntax in Oracle BPM's method editor:
    (PdfGenerator).generate(outputFilename : "", contents : {  }, logoImageURL : null, signatureImageURL : null);
    Assuming you have "outputFilename", "sampleContent", "logoURL" and "signatureURL" variables already created in your process, change the method you just dragged in to:
    IntegrationComponents.Pdfservice.PdfGenerator.generate(outputFilename : outputFilename, contents : sampleContent,
    logoImageURL : logoURL, signatureImageURL : signatureURL);
    Hope this helps,
    Dan

  • How to call the java method in java script function in a portal application

    Hi Friends,
    I am developing one application where i need to fetch the data from KM content and displaying it on the screen in regular interval. I wrote one method in JSPdynpage for fetching data from KM content now I need to call that java method in java script function.
    java method(IComponentRequest request)
    //Coode for fetching the KM content
    function()
    <b>//Need to call the java method</b>
    setTimeout(function, 5000);//setting the time interval for this function
    <<htmlb display code>>
    If anybody can help me in calling the java method in java script function that will be very helpful for me.
    Thanks in advance,
    Sandeep Bonam

    Hi,
    Pls see if the following links could help.
    http://www.rgagnon.com/javadetails/java-0170.html
    http://www-128.ibm.com/developerworks/library/wa-resc/?dwzone=web
    Regards

  • How to call a Java method in a C consoleapplication?

    I have to call a void method of a javaclass using a c consoleapplication. No argument are passed to it.
    I can't make an object of that class..
    This is my implementation in c (using JNI):
    void update(void)
         classn = "<name>";
         cls = (*env) ->FindClass(env, classn );
         if (cls == 0)
    printf(" Can't find class %s\n", classn );
         mid =
    (*env)->GetMethodID(env, cls, "<methodname>", "()V");
         (*env)->CallVoidMethod(obj, env ,m id);
    This goes wrong...
    The problem is that I have no jobject (obj) of the class, because I don't want one...I don't need one. How can I call that void method without an object and only using the classname..??

    You have to make the java method a static method, and use CallStaticVoidMethod.
    "static" means that the method belongs to the class, and not an object of that class.

  • How to call a java method so I can pass a file into the method

    I want to pass a file into a java method method from the main method. Can anyone give me some help as to how I pass the file into the method - do I pass the file name ? are there any special points I need to put in the methods signature etc ?
    FileReader file = new FileReader("Scores");
    BufferedReader infile = new BufferedReader(file);
    Where am I supposed to put the above text - in the main method or the one I want to pass the file into to?
    Thanks

    It's a matter of personal preference really. I would encapsulate all of the file-parsing logic in a separate class that implements an interface so that if in the future you want to start taking the integers from another source, e.g. a db, you wouldn't need to drastically alter your main application code. Probably something like this, (with an assumption that the numbers are delimited by a comma and a realisation that my file-handling routine sucks):
    public class MyApp{
    public static void main(String[] args){
    IntegerGather g = new FileIntegerGatherer();
    Integer[] result = g.getIntegers(args[0]);
    public interface IntegerGatherer{
    public Integer[] getIntegers(String location);
    import java.io.*;
    public class FileIntegerGatherer implements IntegerGatherer{
    public Integer[] getIntegers(String location){
    FileInputStream fs=null;
    try{
    File f = new File(location);
    fs = new FileInputStream(f);
    byte[] in = new byte[1024];
    StringBuffer sb = new StringBuffer();
    while((fs.read(in))!=-1){
    sb.append(new String(in));
    StringTokenizer st = new StringTokenizer(sb.toString(),",");
    Integer[] result = new Integer[st.countTokens()];
    int count = 0;
    while(st.hasMoreTokens()){
    result[count]=Integer.valueOf(st.nextToken());
    count++;
    catch(IOException e){
    //something sensible here
    finally{
    if(fs!=null){
    try{
    fs.close();
    catch(IOException f){
    return result;
    Once compiled you could invoke it as java MyApp c:\myInts.txt
    Sorry if there are typos in there, I don't have an ide open ;->

  • How to call a java method asynchronously

    Hello All,
    I am using a managed bean for calling a method to send email after records are commited, the email is sent through pl sql procedure in oracle database.
    But this procedure takes some time to send the email , due to which the next page navigation becomes slow. I do not want to wait for this procedure to be completed, I want to call this method asynchrounosly. Please advice me .
    Thanks in advance.

    I would not recommend using threads for all possible use cases, but there are some long running use cases which can't run in synchronous mode without putting the user to sleep...
    We have some cases, e.g. generating monthly reports, which take up to 5 hours to compile. I don't like to put all the work into the db because I'll have some legacy systems to work with, so I have to use java anyway.
    There are some lessons to learn, but I did not find a show stopper for my job scheduling (using threads).
    Timo

  • How to call a Java method n map the output of that method to a table in ODI

    Hi,
    I'm new to ODI. I've written an interface which joins two tables( in source ) to a file (in target). Now i have to apply a method(java call) on each element of a column in the target. Now my questions are :
    1. All that i know is to use Procedure using either Jython or Java BeanShell. Can you give some sample commands to achieve such functionality?
    2. Where should i actually apply this procedure? Is it possible to apply this procedure within the Interface during mapping (so that i can directly map the result to the output file)?
    Thanks in advance :)

    VikasKiran wrote:
    1. All that i know is to use Procedure using either Jython or Java BeanShell. Can you give some sample commands to achieve such functionality?Hi Vikash,
    Suppose the java code is like below
    import java.io.*;
    public class FileWrite
    public void writeFile()
    FileOutputStream fos;
    DataOutputStream dos;
    try {
    File file= new File("C:\\MyFile.txt");
    fos = new FileOutputStream(file);
    dos=new DataOutputStream(fos);
    dos.writeInt(2333);
    dos.writeChars("Hello World");
    } catch (IOException e) {
    e.printStackTrace();
    Next we compile the .java class from the command line and create the jar file.
    Then copy and paste the .jar archive to the ODI drivers folder. Next we restart the ODI agent.
    Now call methods in this class from either Jython
    import FileWrite
    fw=FileWrite()
    fw.writeFile()
    or from the Java BeanShell
    import FileWrite;
    FileWrite fw = new FileWrite();
    fw.writeFile();
    2. Where should i actually apply this procedure? Is it possible to apply this procedure within the Interface during mapping (so that i can directly map the result to the output file)?If your method is inside your jar file returning one value then store into one variable.Then use this variable in your interface or procedure wherever you want.
    As GURU told we cannot use procedure inside interface mapping.
    Thanks

  • How to call a C function calling a Java Method from another C function ?

    Hi everyone,
    I'm just starting to learn JNI and my problem is that I don't know if it is possible to call a C function calling a Java Method (or doing anything else with JNI) from another C function.
    In fact, after receiving datas in a socket made by a C function, I would like to create a class instance (and I don't know how to do it too ; ) ) and init this instance with the strings I received in the socket.
    Is all that possible ?
    Thank you very much for your help !

    Hard to understand the question, but by most interpretations the answer is going to be yes.
    You do of course understand that JNI is the "API" that sits between Java and C and that every call between the two must go through that. You can't call it directly.

  • How to call backing bean method from java script

    Hi,
    I would like to know how to call backing bean method from java script.
    I am aware of serverListener and [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    but i am running in to some issues with [AjaxAutoSuggest article|http://www.oracle.com/technology/products/jdev/tips/mills/AjaxAutoSuggest/AjaxAutoSuggest.html]
    regarding which i asked for help in other thread with subject ....Question on AjaxAutoSuggest article (Ajax Transactions Using ADF and J...)
    The reason why i posted is ( though i realise both are duplicates) .. that threads looks as a specific question to that article hence i would like to ask the quantified problem is asked in this thread.
    So could any please letme know how to call backing bean method from java script
    Thanks
    Murali
    Edited by: mchepuri on Oct 24, 2009 6:17 PM
    Edited by: mchepuri on Oct 24, 2009 6:20 PM

    Hello,
    May know how to submit a button autoamtically on onload of page with clicking a welcome alert box. the submit button has managed button too to show a message on console using SOP.
    the problem is.
    1. before loading the page a javascript comes on which i clicked ok
    2. the page gets loaded and the button is there which gets automatically clicked and the managed bean associated with prints a message on console using SOP.
    I m trying to do this through server listener and click listener. the code is(adf jspx page)
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document id="d1" binding="#{backingBeanScope.backing_check4.d1}">
    <af:form id="f1" binding="#{backingBeanScope.backing_check4.f1}">
    <af:commandButton text="commandButton 1"
    binding="#{backingBeanScope.backing_check4.cb1}"
    id="cb1" action="#{beanCheck4.submit1}"/>
    <af:clientListener type="click" method="delRow"/>
    <af:serverListener type= "jsServerListener"
    method="#{backingBeanScope.backing_check4.submit1}"/>
    <f:facet name="metaContainer">
    <af:resource type ="javascript">
    x=confirm("hi");
    // if(x){
    delRow = function(event){
    AdfCustomEvent.queue(event.getSource(), "jsServerListener", {}, false);
    return true;
    </af:resource>
    </f:facet>
    </af:form>
    </af:document>
    </f:view>
    <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_check4-->
    </jsp:root>
    the backing bean code is -----
    public class classCheck4 {
    public classCheck4() {
    public String submit1() {
    System.out.println("hello");
    return null;
    }

  • How to call a bean method from javascript event

    Hi,
    I could not find material on how to call a bean method from javascript, any help would be appreciated.
    Ralph

    Hi,
    Basically, I would like to call a method that I have written in the page java bean, or in the session bean, or application bean, or an external bean, from the javascript events (mouseover, on click, etc...) of a ui jsf component. I.e., I would like to take an action when a user clicks in a column in a datatable.
    Cheers,
    Ralph

  • How to call a Java class from another java class ??

    Hi ..... can somebody plz tell me
    How to call a Java Class from another Java Class assuming both in the same Package??
    I want to call the entire Java Class  (not any specific method only........I want all the functionalities of that class)
    Please provide me some slotuions!!
    Waiting for some fast replies!!
    Regards
    Smita Mohanty

    Hi Smita,
    you just need to create an object of that class,thats it. Then you will be able to execute each and every method.
    e.g.
    you have developed A.java and B.java, both are in same package.
    in implementaion of B.java
    class B
                A obj = new A();
                 //to access A's methods
                 A.method();
                // to access A's variable
                //either
               A.variable= value.
               //or
               A.setvariable() or A.getvariable()

  • How to call a java program in javafx class(Urgent) and even vice versa

    Hi all,
    Here I have two questions:
    1)
    Please let me know how to call a javafx in java program...
    I tried with the following code but it is not working..
    The below is the java program in which I made a call to the Fx program.
    FxMainLauncher.java
    import net.java.javafx.FXShell;
    public class FxMainLauncher {
    public static void main(String[] args) throws Exception {
    FXShell.main(new String[] {"HelloWorld.fx"});
    2) How to call a java program in javafx class
    Here is my javafx program
    import check.*;
    import javafx.ui.*
    var instance = new MyJava();
    //visible:true
    System.out.println("Number is: {instance}");
    Here is my java program
    public class MyJava {
    public static void main(String args[])
    System.out.println("JAVAFX TO JAVA");
    Even this is not working please let me know ASAP
    Thanks in advance,
    V.Srilakshmi

    GOT IT !!!
    I had to change the name of the method in .h file generated by javah command. On doing
    javac -d ../../classes HelloWorld.java
    go to the ../../classes directory (where you have the class file) and do
    javah HelloWorld
    I got a HelloWorld.h file in which I had
    JNIEXPORT void JNICALL Java_HelloWorld_display(JNIEnv *, jobject);
    I added the package name too:
    JNIEXPORT void JNICALL Java_GUI_HelloWorld_display(JNIEnv *, jobject);
    The HelloWorldImp.c file should have the same name (ie with package) and be in the same directory(ie ../../classes)
    compile and build the shared library to get "libhello.so" file
    gcc -c -fPIC -I/usr/lib/j2sdk1.3/include -I/usr/lib/j2sdk1.3/include/linux HelloWorldImp.c
    gives .o file
    gcc -shared -o libhello.so HelloWorldImp.o
    gives .so file
    then run java with the command in my first message. It works.
    Thanks for the reply "thedracle".

  • How to call a java script in while eventprocessing?

    hi friends,
    How to call a java script from an event.
    when i click a button, i want to display a message in IE.
    For ex: BTN_CAN,
    When i click on this in IE i want show a message like "clicked on cancelled".
    how can i do this.....
    in javascript WINDOW.ALERT i am trying....
    Regards,
    Shankar.

    you can do some thing like this...
    < % @  pa g e la ng uag  e="a b ap" %>
    < % @ e xte n sion name="htmlb" prefix="h tm l b"  %  >
    <  h t  m l b:co  nt e nt d es ign="design2 00  3"  >
      <  ht m lb:page title=" "    >
        <  h tm lb :for m  >
           < h t  mlb:textVi ew text   = "Hello World!"
                          des  ign = "EMPHASIZED" />
          < ht  m lb  :bu  tton text          = "Press Me"
                         on  Clie  ntC lick = "al ert(' H ell  w or l d')"  / >
        <  / h t mlb  :for m >
      < / ht mlb :pa g e >
    <   / htm lb:co nt e nt >
    Edited by: Vijay Babu Dudla on Oct 6, 2008 7:20 AM

  • How to call a java script?

    Hi,
    I m new to Indesign and also to MAC OS...
    I ve tried the sdk samples of InDesign CS3 on MAC OS. It works well.
    I m making changes to one of the samples (BasicPanel). I ve added few check boxes and buttons in it. I donno where to give the code for button(in the panel) event/action?
    I also need to know "how to call a java script from InDesign CS3 SDK ?"...
    I have the Scripts ready... Can someone provide the code used to call JS...
    Someone pls help me.....
    Thank You...

            Here s the code to call a Javascript:
            IDFile scriptFile;
            FileUtils::GetAppInstallationFolder(&scriptFile);                    //application folder path
            FileUtils::AppendPath(&scriptFile, PMString("Scripts", -1, PMString::kNoTranslate));               
            FileUtils::AppendPath(&scriptFile, PMString("Scripts Panel", -1, PMString::kNoTranslate));
            //inside the scripts panel, append path of the folder in which ur script is present.
            //Suppose, ScriptsPanel->NewFolder->Link.jsx
            FileUtils::AppendPath(&scriptFile, PMString("NewFolder", -1, PMString::kNoTranslate)); 
            FileUtils::AppendPath(&scriptFile, PMString("Link.jsx", -1, PMString::kNoTranslate));
            InterfacePtr<IScriptRunner>scriptRunner(Utils<IScriptUtils>()->QueryScriptRunner(scriptFi le));
            bool filestatus=scriptRunner->CanHandleFile(scriptFile);
            if(filestatus==1)
                scriptRunner->RunFile(scriptFile,kTrue,kFalse);
    Regards,
    tnhems

  • How to Call Event Handler Method in Another view

    Hi Experts,
                       Can anybody tell me how to call Event handler Method which is declared in View A ,it Should be Called in
      view B,Thanks in Advance.
    Thanks & Regards
    Santhosh

    hi,
    1)    You can make the method EH_ONSELECT as public and static and call this method in viewGS_CM/ADDDOC  using syntax
        impl class name of view GS_CM/DOCTREE=>EH_ONSELECT "method name.
                 or
    2)The view GS_CM/ADDDOC which contains EH_ONSELECT method has been already enhanced, so I can't execute such kind of operation one more time.
                         or
    3)If both views or viewarea containing that view are under same window , then you can get the instance ofGS_CM/DOCTREE from view GS_CM/ADDDOC  through the main window controller.
    lr_window = me->view_manager->get_window_controller( ).
        lv_viewname = 'GS_CM/DOCTREE '.
      lr_viewctrl ?=  lr_window ->get_subcontroller_by_viewname( lv_viewname ).
    Now you can access the method of view GS_CM/DOCTREE .
    Let me know in case you face any issues.
    Message was edited by: Laure Cetin
    Please do not ask for points, this is against the Rules of Engagement: http://scn.sap.com/docs/DOC-18590

Maybe you are looking for

  • How can I enable the standard ctrl-n/ctrl-p shortcuts to navigate dropdowns in Mac OSX?

    In OSX, ctrl-n/ctrl-p are are generally accepted as substitutes for up/down, and those keyboard shortcuts can be used to move the selection up/down in a dropdown menu. Safari and Chrome properly move the dropdown selection, but Firefox does not. Fire

  • Links in Subscriptions emails

    Links in Subscriptions emails do not take you to the new post when clicked. Having to scroll to the new post (when the blue indicators are on) is a pain.

  • Ps3 to imac 21,5

    I want to use my imac screen for ps3. I have an "belkin mini displayport to hdmi converter". I searched on the internet and found out I had to do something with command + f2 or something but i doesn't work. Is it possible to do this and how? I think

  • Enable RDA for customized datasource

    Hi Please let me know step by step process how to enable RDA for customized datasource ( generic extraction by FM) and how tio enable for standard datasource

  • BPM with split synchronous calls and merge

    I need to create a BPM that will take a synchronous request message. The synchronous request message contains a customer ID based on two synchronous web services are called on 2 different systems. The results of these need to be merged and sent back