How may one increase JVM/Java Stored Procedure Perfomance?

Hi all,
my question: How can one increase the performance of the Oracle JVM, especially of Java Stored Procedures?
I ask this because I did some performance analysis (and was horrified :):
I have a static Java method that'll need an average 15 ms to return - when executed locally.
The same code, uploaded to an Oracle10g instance and published as Java Stored Procedure will take awful *925 ms*.
I measured both times from within the method as shown below:
public class JSProc {
public static void doSomething() {
long start = System.currentTimeMillis();
// now comes the '15 ms'-code
long time = System.currentTimeMillis() - start;
That way, I'm not including any call spec overhead, network communication or whatever into the 925 ms. All in all the above procedure call will take about 1200 to 1500 ms until it returns to the client...
The hardware: both client/server computers have the same hardware, both use the JDK provided with the latest Oracle10g release; single difference: client is Win2K, server is Linux.
I would be immensely grateful for your suggestions concerning the possibilities to increase the JVM performance...
Greetings,
Sam

As Avi suggested, subsequent calls of the procedure within the same session will reduce the execution time down to 40 ms in my testing environment.
But that doesn't change anything for the 'first call' - when I start a new client program that opens a new connection, the Java Stored Proc will again need about a second to return.
I wrote the procedure now in PL/SQL - it will return in less than 30 ms, subsequent calls will return in less than a ms. Guess what I'll use :)
I played around with the JAVA* configuration params, but, as expected, that doesn't change anything in terms of performance. According to documentation, it will only affect the amount of classes I can load into the server.
I just read that Oracle creates a new "little" JVM for every session, and I imagine that there's lot of method intercepting and things (the ominous AOP-code) to ensure transaction security.
That's why I come to the conclusion that I won't use Java Stored Procedures for classical "connect, execute, disconnect" client-server applications. It's like full braking on the freeway :)

Similar Messages

  • How to debug noclassdeferror from java stored procedure.

    Hi,
    I am making use of OracleSoapHttpConnection class to call a webservice from a java stored procedure. I used loadjava to load the soap.jar, everything loaded without any error. We can see the "OracleSoapHTTPConnection" class loaded in the all_objects table, still during runtime we get noclassdeferror. I am not sure on how to set classpath for oracle database jvm.
    Many Thanks.
    Chandana

    Please don't post duplicate messages in the forum. You're just cluttering up the place. How to resolve a noclassdeferror for OracleSoapHttpConnection class
    Cheers, APC

  • Help with use of Java Stored Procedures to invoke Java Code within Applicat

    Good afternoon everyone
    Our development team is looking for some assistance/validation of a design strategy we are deploying for a client. Let me first layout the environment and then the design issue at hand:
    Business User Workstation component: Oracle SQL*Developer 1.5.x
    Reporting Tool: Actuate e.Spreadsheet A10
    Application Web UI: J2EE application developed with Eclipse
    Application Scripting: Application has a scripting component whereby business users can write Oracle PL/SQL to perform many of the functions that are available in the Web UI, but can be batched up or repeated several times.
    Application Server WebLogic 9.2.3 (client constraint)
    Database Serve: Oracle 11g, Release 11.1.0.7
    Lots of other stuff included but irrelevant for this conversation.
    Here's the scenario in question:
    1.     Through the scripting solution, the application user must use PL/SQL to invoke functionality within the Web UI. All PL/SQL that the application user creates does not contain any SQL. Instead our security model mandates that “pre-defined” routines will perform all of the SQL operations against the database; the application user simply invokes the stored procedures of functions to perform activities in the database.
    2.     There is a component of the scripting application that facilitates the creation of reports. In our application, we are using Actuate’s e.Spreadsheet Engine to create the report and format the report based on a template. The template is provided as input, as well as other data items, into Actuate for processing. The net result is the report is created by the Actuate e.Spreadsheet engine in pdf format and then sent back to the user for distribution to other users in the company.
    3.     The Actuate e.Spreadsheet engine consists of one or more JAR files within the Application Server framework. The Web UI utilizes these JAR files as well to perform report generation and data manipulation activities. In the case of the reporting functionality, the pdf report that is generated by Actuate is returned into either the Web UI or into the scripting component for persistence in the database. The mechanism exists to create multi-step jobs that can create multiple reports in one run.
    4.     So to facilitate the above, we are creating one or more Java Stored Procedures that will mediate the communication between the PL/SQL the user’s create and the Java components that are required for business processing. PL/SQL will invoke one or more Java Stored Procedures. Then the Java Stored Procedures invoke Actuate e.Spreadsheet, generate the report, saves the report in the database and returns control back to the invoking procedure.
    So the question is: Is this a viable and correct use of Oracle Java Stored Procedures. What are the advantages/disadvantages of doing so? Any security issues or potholes that you can think of? Tuning issues for the JVMs? Any white papers that you can think of?
    For any Oracle employees that respond, material such as Oracle Whitepapers, etc. would be great.
    I can be contacted at (313) 227-4350 or at [email protected]
    Thanks in advance.

    So are you planning on loading the entire e.Spreadsheet engine into the database server's JVM?
    If so, I would expect that to work, but I expect that you'd have some performance issues. I'd expect that the process of building these PDFs is going to be relatively expensive. Tuning the database server's JVM tends to be rather more challenging than tuning JVM's in an app server.
    If not, I'm not sure how the Java stored procedure would invoke the e.Spreadsheet engine on the application server. It is possible to use Oracle AQ to send a JMS message, but I don't think you can use the standard J2EE JMS APIs-- I think you'd have to use Oracle's AQ interface.
    Justin

  • How to use signed classes/Jars in Java Stored Procedure?

    I am using java encryption API in my java application that I want to deploy as java stored procedure. The API is kept in the signed jar files.
    The Application is running in the MS-DOS environment but not in Oracle8i.
    It gives me following error.
    java.lang.ExceptionInInitializerError: java.lang.SecurityException: Cannot set
    up certs for trusted CAs
    at javax.crypto.b.<clinit>([DashoPro-V1.2-120198])
    at javax.crypto.KeyGenerator.getInstance([DashoPro-V1.2-120198])
    at DesKey.GenerateKey(DesKey.java:63)
    declare
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.ExceptionInInitializerError
    ORA-06512: at line 4
    (Note: I have enabled the java output in SQL Plus editor otherwise it will give only the second part of error that starts from ERROR at line 1:)
    please guide me how to solve this problem.
    Salman Hameed

    Salman,
    If you do not get a reply on this forum, I recommend you post this question on the Oracle JVM discussion forum as well.
    In addition, I would recommend checking the documentation for Oracle8i. The Oracle8i Java Developer's Guide, the Java Stored Procedures Guide, and the JDBC Developer's guide may have some information on this topic. You can get to this doc from the OTN Documentation page. Click on Oracle8i, then General Documentation, Release 2 (8.1.6), then scroll down to see the link for the Oracle8i Java Developer's documetation. All of the books mentioned above are available from that link.

  • How to deploy signed jars/classes in Java Stored Procedure

    I am using java encryption API in my java application that I want to deploy as java stored procedure. The API is kept in the signed jar files.
    The Application is running in the MS-DOS environment but not in Oracle8i.
    It gives me following error.
    java.lang.ExceptionInInitializerError: java.lang.SecurityException: Cannot set
    up certs for trusted CAs
    at javax.crypto.b.<clinit>([DashoPro-V1.2-120198])
    at javax.crypto.KeyGenerator.getInstance([DashoPro-V1.2-120198])
    at DesKey.GenerateKey(DesKey.java:63)
    declare
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.ExceptionInInitializerError
    ORA-06512: at line 4
    (Note: I have enabled the java output in SQL Plus editor otherwise it will give only the second part of error that starts from ERROR at line 1:)
    please guide me how to solve this problem.
    Salman Hameed
    null

    Salman,
    If you do not get a reply on this forum, I recommend you post this question on the Oracle JVM discussion forum as well.
    In addition, I would recommend checking the documentation for Oracle8i. The Oracle8i Java Developer's Guide, the Java Stored Procedures Guide, and the JDBC Developer's guide may have some information on this topic. You can get to this doc from the OTN Documentation page. Click on Oracle8i, then General Documentation, Release 2 (8.1.6), then scroll down to see the link for the Oracle8i Java Developer's documetation. All of the books mentioned above are available from that link.

  • How to execute a procedure or function from Java Stored procedure

    Hi,
    I am new to Java Stored Procedures. I am working on Oracle 8i and JVM 1.3.1. I want to call a PL/SQL procedure from within Java. I have tried looking at severa; cources but they are quite high level for me. Can someone provide a simple example including the Source Code for .java file and also the calling function's code?
    Heres a sample of what I have been working on: I an including Java code, and Function code and how I call the function. Instead of doing "select sysdate from dual" I want to do like "create table temp1(var1 varchar2(10))" or similar... like "exec procname(var1)" etc.
    Thanks in advance.
    PS. The variable passed in function is just a dummy variable.
    -----Begin Java code-------
    import java.sql.SQLException;
    import java.sql.PreparedStatement;
    import java.sql.Statement;
    import java.sql.Connection;
    import java.sql.ResultSet;
    //Oracle Extensions to JDBC
    import oracle.jdbc.driver.OracleDriver;
    public class Test2{
    public static String Testing(String d) {
    Connection connection = null; // Database connection object
    try {
    // Get a Default Database Connection using Server Side JDBC Driver.
    // Note : This class will be loaded on the Database Server and hence use a
    // Se[i]Long postings are being truncated to ~1 kB at this time.

    what your after is
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:oci:@<hoststring>", "scott", "tiger");
    CallableStatement cs = conn.prepareCall ("begin ? := foo(?); end;");
    cs.registerOutParameter(1,Types.CHAR);
    cs.setString(2, "aa");
    cs.executeUpdate();
    String result = cs.getString(1);
    a more complete description can be found in the documentation at
    http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm#1001934
    Dom

  • How to retrieve 'long' column with 32K length in Java stored procedure

    For some reasons, we are not using CLOB, BLOB, or BFILE to store large objects and I have to live with LONG. So I wrote a Java stored procedure to insert, select and manipulate a LONG column by retrieving the LONG into a java.lang.String class (which happens to be the Java class mapped to the LONG SQL datatype). It all works fine as long as the length of the value being retrieved is less than the magic figure of 32767 bytes (which is the restriction on LONG and VARCHAR2 datatype in PL/SQL as well). So looks like Oracle's implementation of the JVM limits String values to a max of 32767 bytes. Suggestions on how to overcome this limitation (other classes that you suggest or do I have to move to files)?
    Thanks,
    Jeet
    null

    the jvm has nothing to do with it ...
    this is a pol/sql limitation on parameters in stored procedures.
    and java stored procedures require a clal spec that makes the j-s-p look like a pl/qsl stored proc.

  • How to get connection of the db lite from java stored procedure?

    Hello! All.,
    I have a written java stored procedures to assign sequence keys, and update some tables. The procedure is working as per our need by using the following connection information.
    try {
    int rowFetched = 0;
    Class.forName("oracle.lite.poljdbc.POLJDBCDriver");
    // connect to the database
    Connection conn = DriverManager.getConnection("jdbc:polite:polite",
    "system", "manager");
    My question is, It is possible in db lite to get a default connections like we use in the enterprise database
    conn = new OracleDriver().defaultConnection();
    Could anybody please shed some light on this.
    Thanks in advance.
    Kathir

    Hello Upi! out of curiosity if you happen to know the answer for the following, I do appreciate it.
    Hello! We are using BC/ADF JClient to select and for any DML operation against Oracle Lite database. We may have more than one user(s) log on to our application, so we requires to authenticate oracle lite user credential using JDBC dynamically.
    I am utilizing the features of JCLoginDialog.java and manipulation bc4j.xcfg file. This work real good for accepting username/password credentials dynamically, since we have multiple database in one computer I have to accept DSN name and if possible built my own configuration file.

  • How to call EJB deployed on OC4J from java stored procedure?

    Hello,
    I'd like to call EJB from java stored procedure. My example works fine from command line, but the problem seems to be with deployment of this code into database. Especialy I'm wondering how to reference jars like oc4jclient.jar, ejb.jar, ... from java stored procedure.
    Is there some example how to do that ?
    Can You help me please ?
    Many thanks,
    Radim Kolek,
    Eurotel Prague.

    Hi,
    You may want to check up this thread
    Calling JBoss EJBs from Java stored procedure
    Hope this helps,
    Sujatha.
    OTN Group.

  • How can I implement the connection pool in my java stored procedure

    my java stored procedures (in database 'B') have to connect to another oracle database ,let's say 'A'. And how can I implement the behavior like the so-called connection pool in my java stored procedure in 'B', as below.
    1. database B, has 2 java stored procedures sp1 and sp2
    2. both sp1 and sp2 connects to databse 'A'
    whatever I call the sp1 and sp2 and the database 'A' always only one connected session from sp1 and sp2 in database 'B'.
    THANKS A LOTS...

    my problem is I have a lots of java stored procedures need to cnnect to the remote oracle db, and I hope the remote db can only have a connected session from my java stored procedures in my local db. I try as below
    class sp{
    static Connection conn=null; //the remote db connection,
    public static void sp1(){...}//procedure 1, using conn
    public static void sp2(){...}//procedure 2, using conn,too
    I can 'see' the 'conn' variable if I invoke the sp1() and sp2() from the same client application(maybe sqlplus). But if I invoke the sp1() from client 'A' and invoke sp2() from client 'B' then the sp1() and sp2() can not see the 'conn' variable for each other. I think it's because the two clients cause oracle to create two instances of the class 'sp' and the sp1() and sp2() located in different instance seperately. Thus the sp1() and sp2() can not see 'conn' for each other. They can only see its own 'conn'.
    To connect to the remote db from the java stored procedure is easy but is it possible to connect to the remote db via database link from the java stored procedure at my local db ? If so, then I also archive my goal .
    BTW , thanks a lots...
    andrew :-)

  • How to implement simple java stored procedure

    I'm using Maxdb  7. 6.03.15 (standalone - no SAP) as a Migration Environment to a new centralized SAP solution.
    Most of the work is done in internal DBproc but I need to trig external procedure (those one's written in Java).
    I have already spent too much time to find related information and because I need only very simple triggreing, I don't want to learn and deploy product like NetWeaver ... anyone could give me minimal information on how to do that ...
    If I'm right, I need to configure the MessageServer and develop a minimist java proc that should be able to register the DBproc (java language) inside DB and handle the MessageServer msg generated by my internal DBproc call to the newly registered java proc ?
    I just want to do that as simple as possible, I don't need locking scheme neither multiple request queue ... because I control all access to the DB and all process are completely serialized  (It was a design rule).
    Could anyone help me ?

    Thank's Lars for that quick answer !
    You wrote,
    > AFAIK one development target is to implement UDEs (User Defined Extensions) that will allow the creation of "inside-the-db-code" in >other languages than the one used for the stored procedures.
    did you mean "JavaUdeServer" ? I see some interesting code in source tree about that . I investigate a little about but I miss the binary javaUdeServer code (and I don't want to rebuild the distribution also because of different version). The message returned when I tried to call a registered java stored proc was smoething like 'Impossible to contact UDE server' 
    But the code is still embedded in the kernel (as It can be found in the map files).
    I don't find any documentation on that feature ,is it for security reason ? If so  I'm ready for a 'No disclosure agreement' (It's not a personal request).
    Of course, if the only way is NetWeaver that could be OK but the task seem's to me so heavy regarding my so simple need's  ... if there is a short way (samples ?) to kick me on NetWeaver to reach my goal you're welcome !!
    (Some piece of code on NetWeaver that allow a procedure to call to external java proc that return hostname will be enough ...).
    For you information, (because I have the feeling I got your answer) I already install a trial NetWeaver some week's ago but I don't spent (and I don't have) many times to use It and I have the bad sensation to try driving a big truck only to move a cup of coffee ...(of Java of course !) but perhaps I'm too impatient ?
    Regards,
    Michel

  • How to use a Java Thread in a Java Stored Procedure?

    I am working with java stored Procedures but i have a problem when i use threads.While the thread is running all the processes are blocked because the thread is not detatched.I don't know if it is impossible to use Thread in a java stored procedure.i made many researches but didn't find information about this case of Thread.If someone knows what to do in this case it will be helpfull for me.Thanks

    The JAR is already load by using CREATE JAVA RESOURCE ... or "loadjava -resolve –force -user p/p@SID –genmissing -jarasresource MyJar.jar"
    If we can create a resource by SQL or loadjava, how can I use it in my java code?
    Edited by: 847873 on 28 mars 2011 06:05
    Edited by: 847873 on 28 mars 2011 06:07

  • How to debug java stored procedures using jdwp with Eclipse IDE?

    I need to debug the java stored procedures loaded in Oracle 9.2.0.6. The java files are loaded into the database using dbms_java.loadjava('-force -debug -verbose -resolve lib/java_stored_procs.jar'); The jar contains .java files and the database resolves and compiles them into .class files. Works fine but I need to debug the code. I am tried of the println method since takes too much and too many iterations.
    My IDE is Eclipse 3.1. I want to use the jdwp for debugging in my IDE. Any one who knows the exact steps?
    Thanks a lot.

    I need to debug the java stored procedures loaded in Oracle 9.2.0.6. The java files are loaded into the database using dbms_java.loadjava('-force -debug -verbose -resolve lib/java_stored_procs.jar'); The jar contains .java files and the database resolves and compiles them into .class files. Works fine but I need to debug the code. I am tried of the println method since takes too much and too many iterations.
    My IDE is Eclipse 3.1. I want to use the jdwp for debugging in my IDE. Any one who knows the exact steps?
    Thanks a lot.

  • Java Stored Procedure in one database connecting to muntiple databases.

    Hello,
    I created a Java Stored Procedure in one database(Oracle10g) and successfully open a connection to another database(Oracle10g) using Thin JDBC Driver. I want to actually transfer CLOB data from one DB to another DB. I am concern that by opening a connection another database in Java Stored Procedure, might interfere with oracle and destabilize the instance at some point. Oracle JDBC FAQ (Link: http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#34_13) stated that Yes it could be done but then mentioned the workaround.(if it could be done why do we need a workaround!!!)
    I would like to confirm whether connecting to multiple DB using JDBC Thin Driver in a Java Stored Procedure is supported by Oracle10g or not and whether it has any known issue with it.
    Thanks in Advance!
    Edited by: user649261 on Sep 16, 2008 8:05 PM

    hrishy wrote:
    Thanks i have modified the title so its easy to comprehendWrite the two parts mentioned above and post if you get problems with your code.
    First write code that calls the stored procedure and test that to make sure that it works.
    Then write a simple webservice and test it out to make sure it works. The integration should be trivial after that.

  • How to write call specs for a java stored procedure that takes a nested obj

    Example Class :
    public class B {
    int number;
    String str;
    public class A {
    private B[] _childern;
    public B[] getChildern(){
    return _children
    public static void saveAll(A a) throws SQLException {
    B[] children = a.getChildern();
    for(int i=0; i<children.length; i++){
    saveChild(children);
    public static void saveChild(B ch)throws SQLException {
    // do something
    What would be the call specification for the method A.saveAll(A)? Your help will be apprecited.
    Thank you
    Ajmal

    In other words, How to pass a Java Object from a Java stored procedure to a Java client ???
    Hello,
    I don't know to deal with a Vector object that has been generated from a stored procedure.
    Should I create first in the JDBC client and pass it as argument to the procedure ?
    Thanks in advance. Here is an extract ...
    On the client side :
    <<
    Vector buffer = new Vector();
    CallableStatement call =
    con.prepareCall ("{call my_procedure_run (?, ?)}");
    call.registerOutParameter(2, java.sql.Types.JAVA_OBJECT );
    call.setString (1, "bla bla bla");
    call.setObject (2, buffer);
    call.execute ();
    buffer = (Vector)call.getObject (2);
    >On the Java stored procedure
    <<
    public class my_procedure
    public static void Run(String input_value, Vector buffer)
    // ??? Vector buffer = new Vector();
    try
    while ( true )
    buffer.addElement(...) ;
    catch(Exception ex) { }

Maybe you are looking for