Java Stored Performance

I was wondering if there is any applied techniques/best practices for enhancing the performance of the "first java call" per session.

I was wondering if there is any applied techniques/best practices for enhancing the performance of the "first java call" per session.

Similar Messages

  • Java stored proc performance parsing XML docs

    Hi
    We are using ORACLE 8i(8.1.6). I have a JAVA Stored procedure that parses XML doc and returns tha values. If I am testing on the box, I get an avg. return time of 2 secs. If I have 20 users, my return time for all went to 25 to 35 secs?
    Are there any parameters on ORACLE I can modify to increase the performance. We are developing app for 1000 to 1500 users. I dont want to guess the time based on my test with 20 users.
    Any help will be greatly appreciated.
    Thank You
    Raju

    Raju,
    Oracle 8.1.7 should be better choice for you since it does have the XML stuff
    natively compiled.
    Regarding scaleability the JVM should scale
    very well. However let us know what you find.
    - Stefan

  • Performance problem with java stored procedure

    hi,
    i developped a java class, then I stored it in Oracle 8.1.7.
    This class contains several import of other classes stored in the database.
    It works, but the execution perfomances are disappointing. It's very long. I guess, that's because of the great number of classes to load that are necessary for my class execution.
    I tried to increase the size of the java pool (I parameter 70 Mo in the java_pool_size parameter of the init.ora), but the performance is not much better.
    Has anyone an idea to increase the performance of this execution of my class ?
    In particular, is there a way to keep permanently in memory the java objects used by my class ?
    Thanks in advance
    bye
    [email protected]
    null

    before running Java, the database session needs to be Java enabled; this might be the reason why it is taking so long. If this is the case, you should see an improvement in subsequent calls, once a database session is Java enabled, other users can benefit from it.
    Kuassi
    I have some performance issue with java stored procedure. Hope some one will be able to help me out. I'm using java stored procedures in my application and basically these procedures are used to do some validation and form the XML message of the database tables. I have noticed that when I call the PL/SQL wrapper function, it is taking time to load the java class and once the class is loaded the execution is faster. Most of the time is spent for loading the class rather than executing the function. if I reduce the class load time, I can improve the performance drastically. Do any one of you know how to reduce the class load time. The following are the platform and oracle version.
    O/S: IBM AIX
    Oracle: 8.1.7

  • Java stored procedures performance ....

    I am currently evaluating the use of Java stored procedures, but
    have so far found the performance to be incredibly poor. If I
    write a simple piece of SQL to insert 1 row to a 2 column table
    via a standalone JDBC application, the average elapsed time over
    5 runs is approx 24 milliseconds. If I move the same piece of
    code to a Java stored procedure, the elapsed time increases (on
    average) to 28 seconds ! Surely this shouldn't be the case; I
    had expected the performance to increase rather than plummet as
    is the case. The DBA team cannot find anything amiss in the
    database, & we are basically scratching our heads as to what the
    problem is. Is there something fundamental that needs to be done
    the database for a Java implementation ??
    ANY IDEAS ANYONE ???????
    nb: database ver 8.1.5, running on Solaris 5.7
    regards,
    Paul.
    null

    Try running long queries. In 8.1.6, we are concentrating more
    on increasing the performance of JDBC driver inside the server.
    Paul Jones (guest) wrote:
    : I am currently evaluating the use of Java stored procedures,
    but
    : have so far found the performance to be incredibly poor. If I
    : write a simple piece of SQL to insert 1 row to a 2 column table
    : via a standalone JDBC application, the average elapsed time
    over
    : 5 runs is approx 24 milliseconds. If I move the same piece of
    : code to a Java stored procedure, the elapsed time increases (on
    : average) to 28 seconds ! Surely this shouldn't be the case; I
    : had expected the performance to increase rather than plummet as
    : is the case. The DBA team cannot find anything amiss in the
    : database, & we are basically scratching our heads as to what
    the
    : problem is. Is there something fundamental that needs to be
    done
    : the database for a Java implementation ??
    : ANY IDEAS ANYONE ???????
    : nb: database ver 8.1.5, running on Solaris 5.7
    : regards,
    : Paul.
    Oracle Technology Network
    http://technet.oracle.com
    null

  • ORA-04030: out of process memory when using Java Stored Procedures

    Hello,
    I have a problem using Java Stored Procedures in Oracle 10g.
    My Java application performs http posts to a webservice and the response is parsed in order to populate some DB tables.
    There is a scheduled job which calls the Java Stored Procedure every x minutes.
    No matter of the 'x minutes' values - after about 160 - 200 calls I get this error:
    ORA-04030: out of process memory when trying to allocate 1048620 bytes (joxp heap,f:OldSpace)
    ORA-04030: out of process memory when trying to allocate 2097196 bytes (joxp heap,f:OldSpace)
    The job stops just while is posting the http request. The weird thing is that almost each time the first http post request I get this error:
    java.net.ConnectException: Connection refused
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
         at java.net.Socket.connect(Socket.java:426)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(DashoA6275)
         at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:140)
         at org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory.createSocket(SSLProtocolSocketFactory.java:130)
         at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
         at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
         at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
         at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
         at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
    and the second try works fine.
    So, The out of process memory occured each time just before getting such an error, and I suspect to be a connection between these errors.
    Tech details:
    1. OS: WinXP
    2. Oracle 10.1.0.2.0
    3. To perform http post I use HttpClient 3.1 from Apache.
    4. I checked the http connection to be closed each time, and this is done.
    5. I checked the oracle statement and connection to be closed each time and this is done
    6. The JVM error (logged in .trc files of Oracle) is:
    java.lang.OutOfMemoryError
         at java.lang.Thread.start(Native Method)
         at sun.security.provider.SeedGenerator$ThreadedSeedGenerator.run(SeedGenerator.java:297)
    DB Settings details:
    Starting up ORACLE RDBMS Version: 10.1.0.2.0.
    System parameters with non-default values:
    processes = 200
    sessions = 225
    shared_pool_size = 159383552
    large_pool_size = 8388608
    java_pool_size = 104857600
    nls_language = AMERICAN
    control_files = C:\ORACLE\PRODUCT\10.1.0\ORADATA\XXXXXX\CONTROL01.CTL, C:\ORACLE\PRODUCT\10.1.0\ORADATA\XXXXXX\CONTROL02.CTL, C:\ORACLE\PRODUCT\10.1.0\ORADATA\XXXXXX\CONTROL03.CTL
    db_block_size = 8192
    db_cache_size = 29360128
    compatible = 10.1.0
    fal_client = XXXXXX
    fal_server = XXXXXXs
    log_buffer = 524288
    log_checkpoint_interval = 100000
    db_files = 70
    db_file_multiblock_read_count= 32
    db_recovery_file_dest = C:\oracle\product\10.1.0\flash_recovery_area
    db_recovery_file_dest_size= 2147483648
    standby_file_management = AUTO
    undo_management = AUTO
    undo_tablespace = undotbs_01
    undo_retention = 14400
    remote_login_passwordfile= EXCLUSIVE
    db_domain =
    dispatchers = (PROTOCOL=TCP) (SERVICE=XXXXXXXDB)
    remote_dependencies_mode = SIGNATURE
    job_queue_processes = 4
    parallel_max_servers = 5
    background_dump_dest = C:\ORACLE\PRODUCT\10.1.0\ADMIN\XXXXXX\BDUMP
    user_dump_dest = C:\ORACLE\PRODUCT\10.1.0\ADMIN\XXXXXX\UDUMP
    max_dump_file_size = 10240
    core_dump_dest = C:\ORACLE\PRODUCT\10.1.0\ADMIN\XXXXXX\CDUMP
    sort_area_size = 1048576
    sort_area_retained_size = 1048576
    db_name = XXXXXX
    open_cursors = 500
    optimizer_mode = FIRST_ROWS
    pga_aggregate_target = 25165824
    Any help would be appreciated. Thanks.
    Can be a problem with JVM threading under Oracle ?

    The server prcess failed to allocate more memory for large objects ( in Oldspace).
    If you Google ORA-04030, you will see several recommendations to work around this.
    The Java VM in the database already has HttpClient, i don't know why you are loading the Apache HttpClient but this might not be the surce of the problem.
    Kuassi http://db360.blogspot.com

  • Speed test: PL/SQL vs. Java Stored Procedures

    I performed tests on these two procedures:
    ===========================================
    // Create a Statement
    Statement stmt = conn.createStatement (ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    // Query the table
    ResultSet rset = stmt.executeQuery ("select SIFOB, SIFRA_GU from sezko");
    while (rset.next ()) {
    salary = rset.getInt(1);
    rset.updateInt (1, salary + 1);
    salary = rset.getInt(2);
    rset.updateInt (2, salary + 1);
    rset.updateRow();
    } // while
    conn.commit();
    // Close the RseultSet
    rset.close();
    // Close the Statement
    stmt.close();
    ===========================================
    procedure updateTable is
    cursor c_updateTable is select rowid, SIFOB, SIFRA_GU from sezko;
    begin
    for r_updateTable in c_updateTable loop
    update sezko set SIFOB = SIFOB + 1, SIFRA_GU = SIFRA_GU + 1 where rowid = r_updateTable.rowid;
    end loop;
    commit;
    end;
    ===========================================
    First procedure is written in Java (as Java Stored procedure) and second is PL/SQL.
    Java is about 10x slower than PL/SQL code.
    Can you explain bad performance results?
    thank you
    Matic & Ales

    Hi,
    I suppose the problem is not with the connection object,but with make connection to the database for every executeupdate or executeupdaterow called .Similarly for fetching the data from the database you
    can use the fetch size technique.Please check the 8.1.6 Java Developers guide for using this.
    Update Batching(For Batch updates and commits)
    Fetch Size(For Batch fetching)
    Oracle Row Pre-Fetching
    Regards
    Anand
    null

  • Java stored procedure vs. PL-SQL vs. external java program

    Hi,
    I'm using a stored procedure for running a query and a few consequent updates. Currently I'm using Java stored procedure for that, which was my choice for simplicity on one hand, and running with the DB on the other.
    In my tests, strangely enough it came out that running as java stored procedure was 3-4 times slower than running as a java program outside the database. I don't know how to explain this, and I wonder if switching to PL/SQL will improve the performance of the code.
    Any experiences? recommendations?
    Thanks,
    Dawg

    In my tests, strangely enough it came out that running as java stored procedure was 3-4 times slower than running as a java program outside the database. I don't know how to explain this, and I wonder if switching to PL/SQL will improve the performance of the code.This isn't strange at all. See: Oracle's JVM (Aurora) is an independent Java Virtual Machine implementation, in accordance to specification. It implements all necessary parts of it (I think so). When you use an external JVM (I assume it's Sun's HotSpot JVM) you use completely different product. It is implemented in different way, it has many different code parts.
    One of the biggest differences between Oracle's JVM and Sun's JVM is [Just-in-Time compiler|http://en.wikipedia.org/wiki/Just-in-time_compilation]. Oracle has implemented it only in the 11g version of database, i.e. 2 years ago, while Sun performed it back in 2000 and continues to improve it for the last 9 years. That would explain obvious differences between Java program inside and outside the DB: they are executed in absolutely different worlds. Diffs could be up to 10x times or more - that's not unusual.
    If you are on 10g and want to compare performance of stored Java procedure vs external program, then you might use additional command-line instruction for external program to disable JIT:
    -XintPS. I wouldn't use Java for your task - that's a total overkill. Use simple SP instead.

  • Java Stored Proc Return Types

    Hi,
    I am new to writting java stored procedures. I have some custom network functionality that I have previously implemented in java and I want to make this functionality available to the database.
    In particular my java gets a list of files. What is the best way to return this list of files to PL/SQL. It is a basic list of just the file name, that within PL/SQL i want to itterate through and perform actions based on the names.
    At the moment in Java the method returns a simple array of strings.
    Please advise.
    Thanks
    Ben

    Ben,
    In my opinion, returning an array of strings (as you say you are already doing) is the best way. Are you having trouble with this? If I remember correctly, you will need to convert your java array into a data structure that can be passed to a PL/SQL routine (as a parameter). Is this where you are having difficulty? I recall some sample code on Oracle's OTN Web site that demonstrates how to do this. Have you seen it?
    http://www.oracle.com/technology/tech/java/sqlj_jdbc/index.html
    Good Luck,
    Avi.

  • Can't execute OS-level command from java stored proc

    I've written a couple simple java stored procs, the first of which writes an file and the second attempts a chown on it. I can write the file (which is written as the oracle user) just fine. I need to chown it, but can't. Here's the first proc:
    public static String writefile()
    String fileName = "/joetest/test.xml";
    try {
    File f = new File(fileName);
    FileOutputStream out = new FileOutputStream(f);
    PrintStream p = new PrintStream(out);
    p.println("this is only a test");
    p.close();
    return "create file successful!!!";
    } catch (Exception e) {
    return "Exception occurred writing file:"+e;
    Here's the proc I've been stuggling with:
    public static String chown(String inString)
    String[] command = {"/bin/sh", "-c", "/usr/bin/chown notjoe /joetest/test.xml"};
    if (inString != null) {
    command[2] = inString;
    try {
    Process p = Runtime.getRuntime().exec(command);
    return "Ownership change success!! "+p;
    } catch (Exception e) {
    return "Ownership change failure?? err="+e;
    The package is created with:
    CREATE OR REPLACE PACKAGE JOE.THISISATEST AS
    FUNCTION writefile
    return VARCHAR2
    AS
    LANGUAGE java
    NAME 'thisisatest.writefile() return java.lang.String';
    FUNCTION chown(Param1 VARCHAR2)
    return VARCHAR2
    AS
    LANGUAGE java
    NAME 'thisisatest.chown(java.lang.String) return java.lang.String';
    end;
    And I've granted the following privileges:
    begin
    dbms_java.grant_permission('JOE', 'java.io.FilePermission', '/joetest/test.xml', 'read, write, execute, delete');
    end;
    begin
    dbms_java.grant_permission('JOE', 'java.io.FilePermission', '/usr/bin/chown', 'execute');
    end;
    begin
    dbms_java.grant_permission('JOE', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    end;
    begin
    dbms_java.grant_permission('JOE', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    end;
    Here's the error that I'm getting:
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Coincidentally, this is the same error that I used to get when I wrote the file without having been granted write privileges. Once I granted myself the proper 'write' permissions I could perform file IO just fine. Is there some runtime permission that I need to grant myself to run chown? I'm just guessing, as I can't find any permission like that in the java documentation. I have 'execute' permission on /usr/bin/chown and the oracle user can execute the command I'm attempting from the command line. ARRRRRGH.
    I am at my wits end with this. I've tried what seems like a thousand different syntaxes for the OS command and ran it from many different directories. Anyone have any thoughts at all as to why this is happening? I'm just clutching at straws now...

    Hmmmm. Granting 'execute' on '<<ALL FILES>>' to user JOE fixes this problem:
    begin
    dbms_java.grant_permission('JOE', 'java.io.FilePermission', '<<ALL FILES>>', 'execute');
    end;
    My security folks will not allow this when I port to production, but at least it is something.
    Message was edited by:
    user603023

  • Java Stored Procedure calling HTTP Servlet in Weblogic

    I am currently working on an e-commerce application for a brick-n-mortar electronics store. The store currently has an Oracle database that contains all of the products the store sells. The e-commerce site will have a separate Oracle database. Both database are Oracle 9i release 2 databases. The e-commerce site will be using BEA's Weblogic as its application server. I need to move data from the store db into the e-commerce db. The actual moving of the data is not the issue. The issue comes from needing to call several methods on a Stateless Session EJB, loaded on the Weblogic server, to perform backend processing. I wanted to make a JNDI call from a Java Stored Procedure but with Release 2, this option is no longer supported. The release notes (http://otn.oracle.com/tech/java/htdocs/9idb2_java.html) indicated that the JVM now supports calling out to Servlets using HTTP Client from a Java Stored Procedure.
    Has anyone done this? Is there any sample code available?
    Thanks for any help.

    I am currently working on an e-commerce application for a brick-n-mortar electronics store. The store currently has an Oracle database that contains all of the products the store sells. The e-commerce site will have a separate Oracle database. Both database are Oracle 9i release 2 databases. The e-commerce site will be using BEA's Weblogic as its application server. I need to move data from the store db into the e-commerce db. The actual moving of the data is not the issue. The issue comes from needing to call several methods on a Stateless Session EJB, loaded on the Weblogic server, to perform backend processing. I wanted to make a JNDI call from a Java Stored Procedure but with Release 2, this option is no longer supported. The release notes (http://otn.oracle.com/tech/java/htdocs/9idb2_java.html) indicated that the JVM now supports calling out to Servlets using HTTP Client from a Java Stored Procedure.
    Has anyone done this? Is there any sample code available?
    Thanks for any help. Hi,
    sorry we have not yet formally documented this but here is a code snippet
    Kuassi
    /* HttpCallout - simple test to callout to static pages from Java Stored
    Procedures */
    import java.io.IOException;
    import java.io.InputStream;
    import HTTPClient.HTTPConnection;
    import HTTPClient.HTTPResponse;
    import HTTPClient.AuthorizationInfo;
    public class HttpCallout {
    public static void main(String[] argv) throws InterruptedException {
    HttpCallout t = new HttpCallout(argv);
    t.run();
    private String[] argv ;
    HttpCallout(String[] argv) {
    this.argv = argv;
    void initSSL() {
    public void run() {
    try {
    if ( argv.length == 0 ) {
    System.out.println("HttpCallout " +
    "protocol " +
    "host " +
    "port " +
    "page ");
    return;
    // process arguments
    int argc = 0;
    String protocol = argv[argc++];
    String host = argv[argc++];
    int port = Integer.parseInt(argv[argc++]);
    String page = argv[argc++];
    // Debugging - don't set for now
    // System.setProperty("HTTPClient.log.mask", "3");
    // noop
    initSSL();
    // Grab HTTPConnection
    HTTPConnection con = new HTTPConnection(protocol, host, port);
    con.setTimeout(20000);
    con.setAllowUserInteraction(false);
    // Grab Response
    HTTPResponse rsp = con.Get(page);
    byte[] data = rsp.getData();
    if ( data == null ) {
    System.out.println("no data");
    } else {
    System.out.println("data length " + data.length);
    System.out.println(new String(data));
    catch ( Throwable ex ) {
    ex.printStackTrace();

  • Java Stored Procedure with LOB as input parameter (oracle 9i 9.2.0.6)

    Hi,
    Is there a way to pass CLOB as input and output as part of java stored proceudre in oracle 9i (9.2.0.6)?
    I have to perform some data conversion on the CLOB data in java program and return the converted CLOB as output.
    --Ramesh Lokineni                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    The reason why I want to use java for conversion is because, I want to perform base64 encoding decoding on the content stored in CLOB column. I tried to use by chunking the data into smaller pieces and apply the base64 encoding, but when I decode the CLOB using base64, I am not getting the same data. Later when I read about how base64 encoding happens I realized chunking the data in CLOB doesn't work. That's when I started to diggin how I can pass CLOB to java stored procedures.

  • Problem in running a java stored procedure&optimum settings for this needed

    hi
    we are using java stored procedures to read huge data from database tables and transfer them to another system.
    the procedure is running fine but it fails after transferring 60000 records, the execution of procedure here does not terminate but keeps running with out performing any data transfer....since it does not give any error it is difficult for us to know what the actual problem is !!!!!!
    i have checked the code many a time and i dont see any infinite loops in that code.
    please give any pointers on why this might be happening?
    please also give all the parameters which need to be taken care of while running a java stored procedure
    thanks
    regards
    asif

    But the same thing works fine with a jdbc program
    the table name is converted
    The same convert.transform method is being used to do the conversion
    please help
    ISQL is similar to SQL prompt inOracle
    it is like,
    ISQL>
    Regards
    khurram

  • Passing Tables back from Java Stored Procedures

    Thomas Kyte has written (in reference to
    trying to pass an array back from a stored
    function call):
    You can do one of two things (and both require the use of
    objects). You cannot use PLSQL table types as JDBC cannot bind to
    this type -- we must use OBJECT Types.
    [snip]
    Another way is to use a result set and "select * from
    plsql_function". It could look like this:
    ops$tkyte@8i> create or replace type myTableType as table of
    varchar2 (64);
    2 /
    Type created.
    ops$tkyte@8i>
    ops$tkyte@8i>
    ops$tkyte@8i> create or replace
    2 function demo_proc2( p_rows_to_make_up in number )
    3 return myTableType
    4 as
    5 l_data myTableType := myTableType();
    6 begin
    7 for i in 1 .. p_rows_to_make_up
    8 loop
    9 l_data.extend;
    10 l_data(i) := 'Made up row ' &#0124; &#0124; i;
    11 end loop;
    12 return l_data;
    13 end;
    14 /
    Function created.
    ops$tkyte@8i>
    ops$tkyte@8i> select *
    2 from the ( select cast( demo_proc2(5) as mytableType )
    3 from dual );
    COLUMN_VALUE
    Made up row 1
    Made up row 2
    Made up row 3
    Made up row 4 [Image]
    Made up row 5
    So, your JDBC program would just run the query to get the data.
    If the function "demo_proc2" cannot be called from SQL for
    whatever reason (eg: it calls an impure function in another piece
    of code or it itself tries to modify the database via an insert
    or whatever), you'll just make a package like:
    ops$tkyte@8i> create or replace package my_pkg
    2 as
    3
    4 procedure Make_up_the_data( p_rows_to_make_up in
    number ); 5 function Get_The_Data return myTableType;
    6 end;
    7 /
    Package created.
    ops$tkyte@8i>
    ops$tkyte@8i> create or replace package body my_pkg
    2 as
    3
    4 g_data myTableType;
    5
    6 procedure Make_up_the_data( p_rows_to_make_up in number )
    7 as
    8 begin
    9 g_data := myTableType();
    10 for i in 1 .. p_rows_to_make_up
    11 loop
    12 g_data.extend;
    13 g_data(i) := 'Made up row ' &#0124; &#0124; i;
    14 end loop;
    15 end;
    16
    17
    18 function get_the_data return myTableType
    19 is
    20 begin
    21 return g_data;
    22 end;
    23
    24 end;
    25 /
    Package body created.
    ops$tkyte@8i>
    ops$tkyte@8i> exec my_pkg.make_up_the_data( 3 );
    PL/SQL procedure successfully completed.
    ops$tkyte@8i>
    ops$tkyte@8i> select *
    2 from the ( select cast( my_pkg.get_the_data as mytableType
    ) 3 from dual );
    COLUMN_VALUE
    Made up row 1
    Made up row 2
    Made up row 3
    And you'll call the procedure followed by a query to get the
    data...
    I have tried this, and it works perfectly.
    My question, is what does the wrapper look
    like if the stored function is written
    in java instead of PL/SQL? My experiments
    with putting the function in java have been
    dismal failures. (I supposed I should also
    ask how the java stored procedure might
    look also, as I suppose that could be where
    I have been having a problem)
    null

    Thanks for the response Avi, but I think I need to clarify my question. The articles referenced in your link tended to describe using PL/SQL ref cursors in Java stored procedures and also the desire to pass ref cursors from Java to PL/SQL programs. Unfortunately, what I am looking to do is the opposite.
    We currently have several Java stored procedures that are accessed via select statements that have become a performance bottleneck in our system. Originally the business requirements were such that only a small number of rows were ever selected and passed into the Java stored procedures. Well, business requirements have changed and now thousands and potentially tens of thousands of rows can be passed in. We benchmarked Java stored procedures vs. PL/SQL stored procedures being accessed via a select statement and PL/SQL had far better performance and scaleable. So, our thought is by decouple the persistence logic into PL/SQL and keeping the business logic in Java stored procedures we can increase performance without having to do a major rewrite of the existing code. This leads to the current problem.
    What we currently do is select into a Java stored procedure which has many database access calls. What we would like to do is select against a PL/SQL stored procedure to aggregate the data and then pass that data via a ref cursor (or whatever structure is acceptable) to a Java stored procedure. This would save us a significant amount of work since the current Java stored procedures would simple need to be changed to not make database calls since the data would be handed to them.
    Is there a way to send a ref cursor from PL/SQL as an input parameter to a Java stored procedure? My call would potentially look like this:
    SELECT java_stored_proc(pl/sql_stored_proc(col_id))
    FROM table_of_5000_rows;
    Sorry for the lengthy post.

  • Java Stored Procedures take longer to execute

    Hi,
    I am doing a comparison of Oracle and Java Stored procedures in terms of execution time. I have created a java stored proc and an Oracle stored proc both of which perform the same task. Upon execution, I find that the java proc takes longer time to execute.
    I have the following qs:-
    Why are Java Stored Procs slower than Oracle Stored Procs?
    How is a java stored proc executed as compared to an Oracle Stored Proc?
    Can someone give a detailed explanation of -
    - how a java stored proc is stored in the database?
    - what happens when it is executed?
    Thanks in advance
    Nusrat

    Why are Java Stored Procs slower than Oracle Stored Procs?java program slower than native code! hold the front page!
    On second thoughts don't bother.
    Cheers, APC

  • Recursing through table / complex return types in Java Stored Functions

    I have a table representing a tree with arbitrary depth, of the form:
    ID NUMBER(10) PRIMARY KEY,
    NAME VARCHAR2(20),
    PARENT NUMBER(10)
    with PARENT being a foreign key for ID, so that top-level nodes in the tree have a NULL PARENT, and other nodes have the ID of their parent node in the PARENT field.
    I want a good way to get a row representing a node as well as all its ancestor nodes recursively up to the top level. I do this a lot in my Java application, and right now it works by just getting each row, checking if PARENT is null, and recursing again until I get the top-level node. Since this recursion is in Java and I do multiple queries it's rather slow, and I'd rather perform this operation in the database (using a Java Stored Function/Procedure or PL/SQL).
    I'm no good at PL/SQL so don't have a clue how to go about doing this sort of thing, and although I can write a Java Stored Function that does the same recursion I do in the application, I don't know how to return the results. I can't return a REF CURSOR type since the results are from multiple queries, and I can't find any documentation about how to return structured types from a JSF.
    If anyone could give me a near-complete PL/SQL listing that does this or (better) help me to complete my Java Stored Function by returning the results in a structured type.

    You are my own personal God (for the day). Thanks, exactly what I needed, and all in one query with no procedural.

Maybe you are looking for