Calling Java App through Oracle 9i Database

Hi there,
I have a Java application that is being invoked through an AFTER INSERT trigger on a table. The trigger calls an Oracle plsql wrapper stored procedure which fires the Java application and passes a parameter value.
Problem: Java application should be invoked only once the commit after the INSERT statement is issued. I am unable to do this by this by using an INSERT trigger as the commit; takes place after the Java app is called?
I know and understand that ON COMMIT TRIGGER IS NOT POSSIBLE IN ORACLE.
Is there any other possible way to solve this problem?
Cheers.
Rohan
Edited by: rbha4 on Oct 11, 2009 8:56 PM

Unless the behaviour of DBMS_SCHEDULER has changed recently, it does a commit as part of the create_job call (or whatever subprogram you use) so is not suitable as a replacement for DBMS_JOB when submitting a job as part of a transaction.
So, what you say is a good approach but using DBMS_JOB.
SQL> create table t1
  2  (col1 number);
Table created.
Elapsed: 00:00:00.02
SQL> insert into t1 values (1);
1 row created.
Elapsed: 00:00:00.00
SQL> select * from v$transaction;
ADDR                 XIDUSN    XIDSLOT     XIDSQN     UBAFIL     UBABLK     UBASQN     UBAREC STATUS
START_TIME           START_SCNB START_SCNW START_UEXT START_UBAFIL START_UBABLK START_UBASQN START_UBAREC
SES_ADDR               FLAG SPA REC NOU PTX
NAME
PRV_XIDUSN PRV_XIDSLT PRV_XIDSQN PTX_XIDUSN PTX_XIDSLT PTX_XIDSQN     DSCN-B     DSCN-W  USED_UBLK  USE
    PHY_IO     CR_GET  CR_CHANGE START_DAT  DSCN_BASE  DSCN_WRAP  START_SCN DEPENDENT_SCN XID
PRV_XID          PTX_XID
000000035DB85B80         10          0    2781184          3       1450       4705         18 ACTIVE
10/12/09 09:30:21    2567038319          9          2            3         1450         4705           18
0000000344DFA6D0       3587 NO  NO  NO  NO
         0          0          0          0          0          0          0          0          1          1  
         0         39          0 12-OCT-09          0          0 4.1222E+10             0 0A00000000702A00
0000000000000000 0000000000000000
1 row selected.
Elapsed: 00:00:00.02
SQL> begin
  2  dbms_scheduler.create_job
  3  (job_name=> 'Adhoc1',job_type=>'PLSQL_BLOCK',
  4  job_action=>'begin null; end;');
  5  end;
  6  /
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.01
SQL> select * from v$transaction;
no rows selected
Elapsed: 00:00:00.01
SQL> Edited by: dombrooks on Oct 12, 2009 9:35 AM

Similar Messages

  • 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.

  • Launch Java app through a bat file

    Hi,
    Because I have to launch my Java App through a batch file, I don't know if I can create a new java class to execute this bat file to launch my Java App? Is that gonna work?
    Henry.

    Yes I created a batch file and tested. If I execute my batch file, the java app will be lauched as expected.
    Here is my java class that execute my batch file
    import java.io.*;
    public class LaunchTest {
    public static void main(String args[])
    String cmd[] = new String[3];
    try
    String osName = System.getProperty("os.name" );
    //System will detect current operating system
    if( osName.equals( "Windows NT" ) || osName.equals( "Windows 2000" ) )
    cmd[0] = "cmd.exe" ;
    cmd[1] = "/C";
    cmd[2] = "c:\\Run.bat"; //Run.bat will set classpath and launch my java app
    else if( osName.equals( "Windows 95" ) || osName.equals( "Windows 98" ) )
    cmd[0] = "command.exe" ;
    cmd[1] = "/C";
    cmd[2] = "c:\\Run.bat";//Run.bat will set classpath and launch my java app
    Runtime rt = Runtime.getRuntime();
    //running the commands
    Process proc = rt.exec(cmd);
    // any error message?
    StreamGobbler errorGobbler = new
    StreamGobbler(proc.getErrorStream(), "ERROR");
    // kick them off
    errorGobbler.start();
                   // any error???
    int exitVal = proc.waitFor();
    catch (Throwable t)
    t.printStackTrace();
    System.out.println("error...");
    And here is my batch file
    @echo off
    set path=e:\jbuilder4\jdk1.3\bin
    set classpath=E:\JBuilder4\jdom-b7\jdom-b7\build\jdom.jar;E:\JBuilder4\jdom-b7\jdom-b7\lib\xerces.jar;.
    d:
    cd AutoTest\classes
    java FirmwareTestPack.FirmwareMainClass
    exit
    When I run the java class above, Dos prompt popped up for a second then disappeared. It did not launch my Firmware pplication.
    Thank you.

  • Calling java code from oracle apps form

    I've created my own java .class file and am attempting to call it from an oracle applications form. I am getting a runtime error while running the form, but I don't know what the error is because nothing is being reported to me.
    I've created the .java file in JDeveloper, compiled it into a .class file, deployed it to a .jar file, and placed it on the application server in a directory that the CLASSPATH can see it. I've added it to the archive parameter of the appsweb.cfg file and see that the .jar file is being downloaded when the JInitiator of Oracle Apps is started.
    I have also imported the .class file into the form via the Program -> Import Java Classes which resulted in PL/SQL package stubs created to call the .class methods.
    When I run the form, the java code is activated on a triggering event, PRE-INSERT. There is no java bean item in a block or on a canvas anywhere. I dont' think I need there to be since I am simply using the java code to perform actions during PRE-INSERT, not to display anything on the canvas.
    I have placed debug messages throughout my code and see that the error is occuring in the PL/SQL packaged stub at the line "JNI.GET_CLASS()" where the parameter to that call is the name of my class. I know it's erroring there because I am handling the "java_error" exception. I am displaying "ora_java.last_error" in the exception handling, but it is null.
    I am at a loss as to determine why I am having problems and how to display an error. Any suggestions? I'm happy to outline my steps and problem in more detail if I have missed something obvious.
    We are using Forms 6.0.8.21.3 with Oracle Apps 11.5.7.
    Shane.

    Shane,
    Don't loose the heart. You have come too close to end.
    The scenario you have mentioned is very unique and something which will fit more in the forms forum. So I think that was a sincere answer to help you and not a "pass the buck" card type game :)
    You are lucky that you got Tapash interested into this issue, otherwise you see there is no OAF component involved out here.
    I have an article promised to some of the guys but will follow this issue.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Calling java application from Oracle forms button

    Hi all,
    I have a problem. The idea is to call Java desktop application when button is pressed. I have used this (above) line of code, but there is no results. When I start form in local everything is fine but when I start from server it doesn't work. Does anyone has that kind of problem and how is solved?
    Thanks in advance.
    __Code is:__
    DECLARE
    v_path VARCHAR2(1000);
    BEGIN
    v_path:= '\\location\Java_Application.jar';
    HOST(v_path);
    END;

    First, please start here:
    http://blogs.oracle.com/shay/2007/03/02/
    As for what you are doing and the problem, it will be difficult to give an exact reason, but here are a few comments which will apply regardless of the platform, version, and installation type.
    1. In most case, when calling HOST from Forms the shell that is started does not include all of the system environment variables. This means for example, if a java.exe is needed (on Windows), you would need to specify its path as part of the call or use a batch file rather than calling a command or app directly. The batch file would first set all the needed environment variables (i.e. PATH, CLASSPATH, etc)
    2. If you are running a newer version of Forms, you have a middle tier. This is were your HOST call will be executed. So, if you are expecting this to occur on the client it will not work. You would need WebUtil for client side calls.
    3. Calling a network resource (i.e. shared drive) is not permitted on Windows platforms when called from a Windows Service. Doing so can be seen as a security vulnerability. This can be overridden, but I would suggest that doing so is not a good idea. All files needed to run your app should be made available locally. If files exist on a remote machine, they should be temporarily brought to the machine (e.g. using ftp, sftp, etc) where they are needed and removed later if necessary. If you are running a newer version of Forms, the Forms runtime process belongs to a Windows Service, even if indirectly as a child.
    4. Calling a jar directly is not the proper way to call a java app. Refer to the following:
    http://download.oracle.com/javase/tutorial/deployment/jar/run.html

  • Sql_trace does not work for Java app using Oracle JDBC thin driver

    Hi,
    I'm using Oracle 8.1.7. I enabled sql trace at instance level by setting sql_trace and timed_statistics to true in init.ora. I restarted the db instance. I wrote a stand-alone java application which used Oracle JDBC thin driver(classes12.zip) to make a connection to my db instance, do some select statements, and close the connection. There were no trace files generated in the folder specified by udump_dest variable. However, if I used sqlplus or dba studio, I saw trace files generated. Has anyone got Oracle sql trace work for JDBC calls from java apps.
    Thanks in advance!

    Hi,
    I'm using Oracle 8.1.7. I enabled sql trace at instance level by setting sql_trace and timed_statistics to true in init.ora. I restarted the db instance. I wrote a stand-alone java application which used Oracle JDBC thin driver(classes12.zip) to make a connection to my db instance, do some select statements, and close the connection. There were no trace files generated in the folder specified by udump_dest variable. However, if I used sqlplus or dba studio, I saw trace files generated. Has anyone got Oracle sql trace work for JDBC calls from java apps.
    Thanks in advance!

  • Invoke Java app from Oracle DB?

    Hi
    I wrote simple Java app I would like to deploy this class to Oracle DB server and to schedule execution, for example, every hour. I wonder how to do that.
    Nenad

    Nenad,
    Although I have not done something like this myself, allow me to suggest the following resources that may help you (assuming you haven't already looked at them).
    Excuse me, but I saw no mention of which Oracle database version you are using, so I have assumed it is 9i.
    For loading java classes into the database, please refer to chapter 2 (Loading Java Classes) of the Java Stored Procedures Developer's Guide.
    For scheduling periodic execution, use the DBMS_JOB (PL/SQL) package.
    Good Luck,
    Avi.

  • How to call java function through Web Service

    Hello Experts,
    I want to call a method through Java Web Service in my abap code. Is it possible ? If so, plz guide me.
    Requirement: In SD module user enters the PAN, on after entering PAN in want to validate it on NSDL. For that a Web Service has already been deployed on a Web Server. and that the deployed Web Service I want to call in abap code.

    Hi,
    check this link
    Re: Call to WS from one backend to other backend
    regards
    afzal

  • How to call java fanction through Web Service

    Hello Experts,
    I want to call a method through Java Web Service in my abap code. Is it possible ? If so, plz guide me.
    Requirement: In SD module user enters the PAN, on after entering PAN in want to validate it on NSDL. For that a Web Service has already been deployed on a Web Server. and that the deployed Web Service I want to call in abap code.

    Hi,
    check this link
    Re: Call to WS from one backend to other backend
    regards
    afzal

  • How to call java function in Oracle forms?

    Hi I am having Oracle 9i with 10g Developer Suite.
    I am new to Oracle forms..
    I had one function in java getDatas()..
    How can I call this function in Oracle Forms..
    Pls help
    Thanks

    Thanks Francois,
    I want to display values from my java code in the Forms..
    For that purpose only i am installing 10g Developer Suite..
    The below is java code..
    public class DBTest {
              public static String callDB(int id,String name){
              String ss="Hai";
              Connection con=null;
              try{
                   Class.forName("oracle.jdbc.driver.OracleDriver");
                   con = DriverManager.getConnection("url","id","pwd");
                   Statement st=con.createStatement();
                   System.out.println("Connected...");
              int r=st.executeUpdate("Insert into FORM_TEST VALUES('"+id+"','"+name+"')");
                   if(r==1){
                        ss="Inserted Sucessfully";
                   else{
                        ss="Insertion Failed";
              }catch(final Exception e){
              System.out.println(e);
              return ss;
         public static void main(String[] args) {
              int empid=102;
              String empname="Gilbert";
              String resultStr=callDB(empid,empname);
              System.out.println(resultStr);
    I want to dispaly Inserted or Insertion Failed in Oracle Forms..
    As per Gerd Volberg suggestion, i had placed DBTest.jar in
    E:\DevSuite\forms\java\DBTest.jar
    and in formsweb.cfg the below jar is added..
    archive_jini=frmall_jinit.jar,DBTest.jar
    But in Fomrs Builder-->Program-->Import Java Classes-->Oracle
    org,ice,com and subnodes are available.
    But my jar is not available..
    Is my way is coorect?
    Pls provide soln..
    Thanks

  • Calling JAVA components through BPEL?

    How can BPEL call JAVA components? If there any different adapter ??
    Pls respond...thanks in advance.

    Hi,
    there are two ways:
    generate a webservice from your java component
    http://download-east.oracle.com/docs/cd/B31017_01/web.1013/b28974/devjavaclass.htm#BHCEGEJA
    or
    embed your java into the bpel
    http://download-east.oracle.com/docs/cd/B31017_01/integrate.1013/b28981/java.htm#sthref1282

  • Calling Java screens from Oracle Forms application

    I am working with a client that has a large Oracle forms application. Since rewriting the entire application in Java is not an option at this time, the strategic direction is that any new modules that are to be created for the application are to be done in Java and called from the Forms menu. The decision as to what tool to use to develop the Java modules is still under debate. What is the best (most seamless) way to do this...calling a Java screen from a Forms application? If anyone has any experience in this, or can direct me to some literature on it, it would be greatly appreciated. Thanks.

    This is a web app in Forms/Reports 10g R2 running off Oracle AS and an Oracle db. The challenge for us is that the direction is that any new enhancements (screens) are to be built using Java (in either ADF Faces or Swing, another point for debate later) and then called from the Forms app. The business client is only paying for the enhancement. They don't care about moving off Forms to Java, so any extra work on the part of IT to do this, has to be fairly minimal and doable within the project budget. The movement to Java is an IT direction. Is there a way to do this without having to build a java framework for the entire Forms application (which I assume would take some time and involve retesting the entire app)?

  • Calling Java Constructor from Oracle Stored Procedure

    Hi all,
    I have come across a situation where on insert into one Oracle database instance, a trigger will be fired which will call a procedure which in turn calls a Java constructor with 2 string arguments(The Java class is loaded into another instance of Oracle using Loadjava).
    (Note: I don't want to call a static method from the Oracle procedure)
    I have seen some examples where in using links, on insertion into a table another table of another instance can also be updated.
    for ex: "INSERT INTO testuser.sal_audit@mainlink VALUES (?, ?, ?)" where "mainlink" is a DB link between the 2 instances.
    Similarly is it possble to call the Java constructor loaded in another instance?
    I have tried in this way. It's not working.
    create or replace procedure pr_Cust_object(FeData varchar2,szDummy varchar2) as
    LANGUAGE JAVA NAME
    'CustomObject@mainLink(java.lang.String, java.lang.String)';
    end pr_Cust_object;
    Expecting help at the earliest--ASAP.
    Thanks and Regards,
    Narendra S K

    I don't know how to do that, but I would be interested in knowing how long each insert/update/delete (which ever the trigger fires on) takes.
    And the logic for rollbacks is probably really interesting.

  • Deploy Java apps using Oracle Apps Server 9i

    Hi Gurus,
    Is it possible to deploy custom Java application using the bundle E Business Suite Apps Server?
    If yes, can you provide me a reference or a step by step guide that will help me do so.
    Many thanks

    Portal 10.1.2 is not yet JSR-168 compliant. You will not be able to deploy a portlet written according to the JSR-168 standard.
    Check http://www.oracle.com/technology/products/ias/portal/standards.html , it contains a link to a developer's preview of the JSR-168 compliant container.

  • Calling java class in oracle procedure

    i have one simple java program that prints 'hi' . i want to call that java program from pl/sql procedure.how to do that.

    This is one method I am demonstrating.
    SQL> CREATE or REPLACE AND COMPILE JAVA SOURCE NAMED "HiWorld" AS
      2  public class HiWorld {
      3 
      4   public static void MyMessage(String msg) {
      5    // TODO Auto-generated method stub
      6    System.out.println(msg);
      7    }
      8 
      9  }
    10  /
    Java created.
    SQL> CREATE or replace PROCEDURE hi_world (p_command  IN  VARCHAR2)
      2  AS LANGUAGE JAVA
      3  NAME 'HiWorld.MyMessage(java.lang.String)';
      4  /
    Procedure created.
    SQL> BEGIN
      2    DBMS_JAVA.SET_OUTPUT(1000000);
      3    hi_world('Saubhik');
      4  End;
      5  /
    PL/SQL procedure successfully completed.
    SQL> set serverout on
    SQL> /
    Saubhik
    Saubhik
    PL/SQL procedure successfully completed.Another method is loading the class file with "loadjava" command. In that case first step "CREATE or REPLACE AND COMPILE JAVA SOURCE NAMED "HiWorld" AS" is not required.

Maybe you are looking for