Calling java function load and stored in database

Hi ,
I try to call a java fonction loaded and published in database (Oracle 8.1.7.4ee). this function call an OS command ... the PL/SQL call is completed but de command set in parameters function is not execute ... next is the code :
import java.lang.*;
import java.io.*;
public class JShell {
public static void execute (String command) throws IOException {
try {
Process child = Runtime.getRuntime().exec(command);
} catch (IOException e) {
calling this function with java main is OK
import java.lang.*;
import java.io.*;
public class TestJShell {
static public void main(String args[]) throws Exception
JShell.execute(args[0].toString());
java TestJShell 'cp /test/myfile.txt /test/myfile.sav'
copy is donethen when the fuction is loaded and published in database
as
loadjava -user ../.. JShell.class
CREATE OR REPLACE PROCEDURE JShell_exe (Commande in VARCHAR2) AS LANGUAGE JAVA NAME 'JShell.execute(java.lang.String)';run is
CALL ell_exe ('cp /test/myfile.txt /test/myfile.sav');
call is completed but no copy is doneCan somebody help me ? thanking you in anticipation;

Firs things first:
1)Which copy of your class is loaded in the DB ( it seems that you have two different classes JShell and TestJShell ).
2)Do you have permisions for file manipulation ?
3)Do you get any errors ?

Similar Messages

  • Calling java function load an store in database

    Hi ,
    I try to call a java fonction loaded and published in database (Oracle 8.1.7.4ee). this function call an OS command ... the PL/SQL call is completed but de command set in parameters function is not execute ... next is the code :
    import java.lang.*;
    import java.io.*;
    public class JShell {
    public static void execute (String command) throws IOException {
    try {
    Process child = Runtime.getRuntime().exec(command);
    } catch (IOException e) {
    calling this function with java main is OK
    import java.lang.*;
    import java.io.*;
    public class TestJShell {
    static public void main(String args[]) throws Exception
    JShell.execute(args[0].toString());
    java TestJShell 'cp /test/myfile.txt /test/myfile.sav'
    copy is donethen when the fuction is loaded and published in database
    as
    loadjava -user ../.. JShell.class
    CREATE OR REPLACE PROCEDURE JShell_exe (Commande in VARCHAR2) AS LANGUAGE JAVA NAME 'JShell.execute(java.lang.String)';run is
    CALL ell_exe ('cp /test/myfile.txt /test/myfile.sav');
    call is completed but no copy is donethank's for your help

    you might need some more privileges to interact with the system from inside oracle.
    I don't know what those are but I had to give privs to a user to open a socket from java.
    exec dbms_java.grant_permission( 'MIS_ADMIN', 'SYS:java.net.SocketPermission', 'localhost', 'resolve' ) ;
    This allowed the jsp to use localhost. You might need to find a similar permission to grant.

  • Calling Java function thru PL-SQL

    Dear all
    As i am New to JAVA ,Can you plz Tell how we can call Java function thru PL-SQL?
    To activate / deactivate function will be called from the database plug-ins. No need for GUI.
    Using the URL ,The objective is to automate this function.
    Many Thanks
    Edited by: khaja on Jan 18, 2009 12:50 PM

    Khaja,
    Please refer to http://download.oracle.com/docs/cd/B19306_01/java.102/b14187/chthree.htm#CACICFFB
    Please try to avoid asking questions for which you can easily find the answer yourself.
    I had to look this up, and found it in less than 2 minutes.
    Sybrand Bakker
    Senior Oracle DBA

  • Calling Java programs from Oracle Stored Procedure

    Is it possible to call Java programs from Oracle stored procs? If possible Can this be used to exchange data from other applications? Is there a better method/feature in oracle for doing data exchange with other apps?

    If what you mean by Oracle stored procedures is pl/sql then yes.
    You can create a "wrapper" this way:
    CREATE OR REPLACE FUNCTION xmlXform
    in_mapUrl IN VARCHAR2,
    in_inputUrl IN VARCHAR2
    RETURN VARCHAR2
    AS
    LANGUAGE JAVA NAME
    'com.yourcompany.xml2any.xform(java.lang.String,java.lang.String)
    RETURN java.lang.String';
    Then load the java as:
    loadjava -user youruser/youruserpasswd -resolve -verbose lib/xmlparserv2.jar classes/com/yourcompany/xform.class classes/com/yourcompany/xml2any.class
    The java, given the correct permissions, can do anything java can do including communicate with outside applications.
    Is this the "best" way... depends on what you are trying to accomplish.

  • ABAP Calling JAVA Function or Method

    Hi Friend,
    I need help in how to proceed using  ABAP  and Call JAVA Function . I know that  we need to use RFC enabled Function modules. I was able to connect  using JAVA Connector which was provided by SAP For communicating with JAVA Apps. The approach for connecting the JAVA to SAP is working fine.  But I  have browsed through various website but failed to find any information.Now i am looking forward to help from you friends to solve my problems .
    The Requirement is mentioned below:-
      1. Prerequiste for SAP ABAP calling a third Party software which is working in JAVA Platform (like any middle ware which might be hardware or software).
      2. Sample Code  like calling a Text  ' Hello  to the world  calling JAVA from ABAP'.
      3. Steps and process so that it would be helpful.
    Timely help would be appreciated.
    Rajiv Christopher.

    1.Middleware is JCO RFC provider it comes with SAP so no need any third party Adapter.
    2.
    " The ECHOTXT parameter should contain the text of REQUTXT.Information on
    " calling the function module should be returned in RESPTXT, indicating, for
    " example, in which system and when the function module call was processed.
    data:ECHOTEXT type SY-LISEL,
         RESPTEXT type SY-LISEL.
    CALL FUNCTION 'STFC_CONNECTION' DESTINATION '<Your JCO destination name>' " which one you have developed in SM59 as TCP/IP
      EXPORTING
        requtext       = 'ABAP Calls JAVA'
    IMPORTING
       ECHOTEXT       = ECHOTEXT
       RESPTEXT       = RESPTEXT.
    if sy-subrc = 0.
      WRITE:/'---------------------------------------------------------------------'.
      WRITE: / 'establish a link to the ABAP application server with logon data'.
      WRITE:/'---------------------------------------------------------------------'.
      write:/ ECHOTEXT .
      else.
          WRITE:/'---------------------------------------------------------------------'.
      WRITE: / 'Not establish a link to the ABAP application server with logon data'.
      WRITE:/'---------------------------------------------------------------------'.
      endif.
    Check the sample code and Let me know will you get ECHOTEXT ?
    Kanagaraja L
    Edited by: Kanagaraja  Lokanathan on Jan 6, 2010 1:27 PM

  • Call Java functions in a C DLL

    Hi,
    I am develop a dynamic link library in C on AIX that will internally call java functions using JNI. This libaray will be finally used by other C Executable.
    There is only one function in C code i.e. Connect. This function internally use JNI and call java functions. Now while compiling I am facing problems. I think that there is some problem with my makefile.
    The make file is given hereunder:
    JAVA_HOME = /usr/java14
    JAVA_INC = $(JAVA_HOME)/include
    CC = cc
    LD = cc
    # Flags to create a dynamic library.
    DYNLINKFLAGS =  -G -ostdlib -bnoentry -bM:SRE -brtl -bE:Interface.exp
    # files removal
    RM = rm -f
    #------------------------------------- Libs -----------------------------------#
    JAVALIBS      = -L$(JAVA_HOME)/jre/bin/classic/
    LIBS            = -ljvm -lpthread  -lxnet -lnsl -lm -ldl
    #-------------------------------- Dependency rules---------------------------#
    # shared library files
    LIB_FILES = Interface.a
    #-------------------------------------OBJs-------------------------------------#
    # shared libraries object files
    LIB_OBJS    = Interface.o
    all: $(LIB_FILES)
    # create our librarys
    Interface.a: Interface.o
         $(LD) $(DYNLINKFLAGS) $(JAVALIBS) $(LIBS) $(LIB_OBJS) -o $@
    # compile C source files into object files.
    %.o: %.c
         $(CC) $(DYNLINKFLAGS) -L$(JAVA_INC) -c $<
    # clean everything
    clean:
         $(RM) $(LIB_OBJS) $(LIB_FILES)
    # clean the library's object files only
    cleanlibobjs:
         $(RM) $(LIB_OBJS)Now the problem is that the size of the Interface.a file is very small only 552 bytes. whereas the size of Interface.o file is 34428. Which clearly indicates that the problem is with the Interface.a file i.e during linking.
    Can any body help me to figure out the problem.
    Regards,
    Ahmad Jalil Qarshi

    I guess, you are better off to ask this question in a C forum. This is a Java forum, you know.

  • How to call java function from PL/sql in oracle applications

    I am trying to call a java function from plsql procedure. Can any one explain how to call java function, and in which directory I have to store my java function in oracle applications. Do I need to register that java function from Application developer.
    Thanks
    Kranthi

    http://www.oracle.com/technology/tech/java/jsp/index.html
    Good Luck,
    Avi.

  • How to call java function in javascript

    Hello Everyone,
    Can anyone tell me solution that:
    How to call java function in javascript?
    Thanks,
    VIDs

    You can't since Java is running on the server and javascript is running in the browser long after the Java side of things has finished executing. Assuming you're not talking about an applet here.
    But you can make calls back to the server through Ajax. All you need is something like a servlet on the receiving end which you can invoke through Ajax; from that point you can execute any Java code you want.

  • Passing Array of java objects to and from oracle database-Complete Example

    Hi all ,
    I am posting a working example of Passing Array of java objects to and from oracle database . I have struggled a lot to get it working and since finally its working , postinmg it here so that it coudl be helpful to the rest of the folks.
    First thinsg first
    i) Create a Java Value Object which you want to pass .
    create or replace and compile java source named Person as
    import java.sql.*;
    import java.io.*;
    public class Person implements SQLData
    private String sql_type = "PERSON_T";
    public int person_id;
    public String person_name;
    public Person () {}
    public String getSQLTypeName() throws SQLException { return sql_type; }
    public void readSQL(SQLInput stream, String typeName) throws SQLException
    sql_type = typeName;
    person_id = stream.readInt();
    person_name = stream.readString();
    public void writeSQL(SQLOutput stream) throws SQLException
    stream.writeInt (person_id);
    stream.writeString (person_name);
    ii) Once you created a Java class compile this class in sql plus. Just Copy paste and run it in SQL .
    you should see a message called "Java created."
    iii) Now create your object Types
    CREATE TYPE person_t AS OBJECT
    EXTERNAL NAME 'Person' LANGUAGE JAVA
    USING SQLData (
    person_id NUMBER(9) EXTERNAL NAME 'person_id',
    person_name VARCHAR2(30) EXTERNAL NAME 'person_name'
    iv) Now create a table of Objects
    CREATE TYPE person_tab IS TABLE OF person_t;
    v) Now create your procedure . Ensure that you create dummy table called "person_test" for loggiing values.
    create or replace
    procedure give_me_an_array( p_array in person_tab,p_arrayout out person_tab)
    as
    l_person_id Number;
    l_person_name Varchar2(200);
    l_person person_t;
    l_p_arrayout person_tab;
    errm Varchar2(2000);
    begin
         l_p_arrayout := person_tab();
    for i in 1 .. p_array.count
    loop
         l_p_arrayout.extend;
         insert into person_test values(p_array(i).person_id, 'in Record '||p_array(i).person_name);
         l_person_id := p_array(i).person_id;
         l_person_name := p_array(i).person_name;
         l_person := person_t(null,null);
         l_person.person_id := l_person_id + 5;
         l_person.person_name := 'Out Record ' ||l_person_name ;
         l_p_arrayout(i) := l_person;
    end loop;
    p_arrayout := l_p_arrayout;
         l_person_id := p_arrayout.count;
    for i in 1 .. p_arrayout.count
    loop
    insert into person_test values(l_person_id, p_arrayout(i).person_name);
    end loop;
    commit;
    EXCEPTION WHEN OTHERS THEN
         errm := SQLERRM;
         insert into person_test values(-1, errm);
         commit;
    end;
    vi) Now finally create your java class which will invoke the pl/sql procedure and get the updated value array and then display it on your screen>Alternatively you can also check the "person_test" tbale
    import java.util.Date;
    import java.io.*;
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.driver.*;
    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    public class ArrayDemo
    public static void passArray() throws SQLException
    Connection conn = getConnection();
    ArrayDemo a = new ArrayDemo();
    Person pn1 = new Person();
    pn1.person_id = 1;
    pn1.person_name = "SunilKumar";
    Person pn2 = new Person();
    pn2.person_id = 2;
    pn2.person_name = "Superb";
    Person pn3 = new Person();
    pn3.person_id = 31;
    pn3.person_name = "Outstanding";
    Person[] P_arr = {pn1, pn2, pn3};
    Person[] P_arr_out = new Person[3];
    ArrayDescriptor descriptor =
    ArrayDescriptor.createDescriptor( "PERSON_TAB", conn );
    ARRAY array_to_pass =
    new ARRAY( descriptor, conn, P_arr);
    OracleCallableStatement ps =
    (OracleCallableStatement )conn.prepareCall
    ( "begin give_me_an_array(?,?); end;" );
    ps.setARRAY( 1, array_to_pass );
         ps.registerOutParameter( 2, OracleTypes.ARRAY,"PERSON_TAB" );
         ps.execute();
         oracle.sql.ARRAY returnArray = (oracle.sql.ARRAY)ps.getArray(2);
    Object[] personDetails = (Object[]) returnArray.getArray();
    Person person_record = new Person();
    for (int i = 0; i < personDetails.length; i++) {
              person_record = (Person)personDetails;
              System.out.println( "row " + i + " = '" + person_record.person_name +"'" );
                        public static void main (String args[]){
         try
                             ArrayDemo tfc = new ArrayDemo();
                             tfc.passArray();
         catch(Exception e) {
                        e.printStackTrace();
              public static Connection getConnection() {
         try
                             Class.forName ("oracle.jdbc.OracleDriver");
                             return DriverManager.getConnection("jdbc:oracle:thin:@<<HostNanem>>:1523:VIS",
                             "username", "password");
         catch(Exception SQLe) {
                        System.out.println("IN EXCEPTION BLOCK ");
                        return null;
    and thats it. you are done.
    Hope it atleast helps people to get started. Comments are appreciated. I can be reached at ([email protected]) or [email protected]
    Thanks
    Sunil.s

    Hi Sunil,
    I've a similar situation where I'm trying to insert Java objects in db using bulk insert. My issue is with performance for which I've created a new thread.
    http://forum.java.sun.com/thread.jspa?threadID=5270260&tstart=30
    I ran into your code and looked into it. You've used the Person object array and directly passing it to the oracle.sql.ARRAY constructor. Just curios if this works, cos my understanding is that you need to create a oracle.sql.STRUCT out of ur java object collection and pass it to the ARRAY constructor. I tried ur way but got this runtime exception.
    java.sql.SQLException: Fail to convert to internal representation: JavaBulkInsertNew$Option@10bbf9e
                        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
                        at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
                        at oracle.jdbc.oracore.OracleTypeADT.toDatum(OracleTypeADT.java:239)
                        at oracle.jdbc.oracore.OracleTypeADT.toDatumArray(OracleTypeADT.java:274)
                        at oracle.jdbc.oracore.OracleTypeUPT.toDatumArray(OracleTypeUPT.java:115)
                        at oracle.sql.ArrayDescriptor.toOracleArray(ArrayDescriptor.java:1314)
                        at oracle.sql.ARRAY.<init>(ARRAY.java:152)
                        at JavaBulkInsertNew.main(JavaBulkInsertNew.java:76)
    Here's a code snippet I used :
    Object optionVal[] =   {optionArr[0]};   // optionArr[0] is an Option object which has three properties
    oracle.sql.ArrayDescriptor empArrayDescriptor = oracle.sql.ArrayDescriptor.createDescriptor("TT_EMP_TEST",conn);
    ARRAY empArray = new ARRAY(empArrayDescriptor,conn,optionVal);If you visit my thread, u'll see that I'm using STRUCT and then pass it to the ARRAY constructor, which works well, except for the performance issue.
    I'll appreciate if you can provide some information.
    Regards,
    Shamik

  • Calling java functions from c++

    I want to start my program from visual c++ then, call java functions and then calling c++ function. How can i do this?

    Yet another cross-poster: [Calling java functions from c++|http://www.java-forums.org/new-java/12597-calling-java-functions-c.html]

  • Calling a function in a stored procedure

    How to call a function in a stored procedure
    Oracle 11g

    Declare
    varname DATATYPE ;
    BEGIN
    varname:= <Function Name> ;
    END;
    You have to understand the other bits by yourself.
    Read more details at http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/overview.htm#sthref192

  • Call Java function from multithreaded VC++ application

    Friends, I want to call Java function from two threads of a single VC++ application. I can call it from single thread but when I call it from another thread also, JNI_CreateJavaVM() replies with an error.
    Please......help me

    Your posting is ambiguous. My impression is that you have two threads, both trying to create a java VM?

  • How to call java function with parameter from javascript in adf mobile?

    how to call java function with parameter from javascript in adf mobile?

    The ADF Mobile Container Utilities API may be used from JavaScript or Java.
    Application Container APIs - 11g Release 2 (11.1.2.4.0)

  • After i updated my firefox from 3.16 to 4.0.1, have some websites i can't load, and they showed: " database error" but b4 i never got this problem. Can someone tell me why ?

    after i updated my firefox from 3.16 to 4.0.1, have some websites i can't load, and they showed: " database error" but b4 i never got this problem. Can someone tell me why ?

    Nothing is working and I can't find the Roboform toolbar. Your lack of direct support is really irritating- a live chat at least would be helpful.

  • JavaFX : How to call java function that returns hashtable and manipulate

    I have a requirement to {color:#0000ff}create a java object in JavaFX script code{color}. Then call a java function using the created java object. The java function returns hashtable. Then traverse through each element of hashtable. Finally I need to create a similar structure in JavaFX.

    If you need to use a Java class that uses generics you need to take special steps. Since JavaFX does not support generics you need to create a java wrapper to hide the calls that use generics and call the wrapper class from FX.

Maybe you are looking for

  • How do I get iMessage on my mac? I just updated my computer and there is no more updates! What do I do?

    I just updated my macbook air to os x (i think) and there are no more updates available for my computer. I thought imessage came with it but it did not come. How do i get imessage?

  • Can't get rid of my high power consumption (Thinkpad X60 Tablet)

    This is really driving me nuts. On Windows 7, I can achieve a power consumption of around 11-12W (with moderate web surfing usage over WLAN and full screen brightness, just Aero turned off). On Arch, I can't get below 13W *ever* with full screen brig

  • Lighting effects ellipse not shown in CS6

    MI am using CS6 Extended on an HP dv7 Pavillion running Windows 7 Ultimate. It is a 64bit system with 6GB of RAM. Display is NVIDIA GeForce GT230M. I am trying to uses the Filter>Render>Lighting Effects feature. I can get to the option toolbar and pr

  • ThinkPad Bluetooth 2.0 Card 39T0497 on T500

    Does anyone know if the Bluetooth Daughter Card (BDC) for a T61 will work on a T500 Thinkpad? T61 model: 39T0497 T500 model: 42T0969 The difference between these 2 cards is that the T61 is Bluetooth 2.0 and the one for the T500 is Bluetooth 2.1 But o

  • File system - XI - ICH ( SCM 5.1 ) sytsem

    Dear XI experts, I have a scenario of XML file - XI - ICH system. I have around 3 yrs of ABAP + XI experience but have never worked on XI - ICH integration. kindly let me know. 1. what type of RFC destination is required to establish connectivity..ho