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) { }

Similar Messages

  • Calling JPA from a Java Stored Procedure

    Is it possible to call JPA from a java stored procedure? If so, does anyone have example? How do you setup the persistence.xml?
    How does the peformance compare with straight JDBC in a java stored procedure?
    Thanks for any help!
    Johnny

    Hi Johnny:
    Basically you can run any JDK 1.5 framework inside your Oracle 11g JVM, I have experience integrating Lucene IR library as a new [Domain Index for Oracle 11g/10g|http://docs.google.com/View?id=ddgw7sjp_54fgj9kg] .
    I am not familiar with JPA internals but my advice is howto handle the connection inside the OJVM and the configuration files.
    Some time ago I took a look to SpringFramework integration and I found that writing a new ApplicationContext class which handles the loading of beans.xml from XMLDB repository instead a file should be enough to work.
    Another important point is the life cycle of the [Oracle internal JVM|http://download.oracle.com/docs/cd/E11882_01/java.112/e10588/chtwo.htm#BABHGJFI]. Unlike an standard JVM the OJVM is created once you first connect from the middle tier at OCI level and remains in execution during the connection pool existence.
    I mean, if you connect using a JDBC pool the JVM will remains running across multiple soft open/close connections of your middle tier application. This is good because you can read your persistence.xml file using a Singleton class and this expensive operation will be re-used by multiple open/close operation done from the middle tier.
    I suggest you do a simple Proof of Concept with a Hello World application and check if it works.
    Remember that any security issues will be notified to the .trc files, security issues are related to the strong security layer configured by default inside the OJVM, for example you can not read any files from the OS file system without an specific grant, you need another grant to access to the class loader and so on, but you can simply grant this specific needs to a database role and then grant this role to the user which connect to the OJVM.
    Another important point is related to the [End-of-Call Optimization|http://download.oracle.com/docs/cd/E11882_01/java.112/e10588/chtwo.htm#BABIFAAI] this can be useful if you want to perform some clean up in your Singleton class at the level of per-statement execution.
    Best regards, Marcelo

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

  • Calling external servlet from java stored procedure

    Hello,
    I need to call an external servlet which is in 9iAS server ( unix box) from Java Stored procedure in oracle database.
    Can anybody give me an idea? is it possible?
    Thanks,
    Viswa

    I am trying the same. Here is URL which will help u.
    http://otn.oracle.com/sample_code/tech/java/jsp/samples/wsclient/Readme.html
    Let me know when you run servlet successfully.
    Regards
    Satish

  • CLASSPATH configuration for jsp (java stored procedures)

    Hi.
    I have a very simple question for you people.
    I don't know where to set up the CLASSPATH configuration on a HP-UX so that Aurora can see this include jar file and my java stored procedure can run correctly.
    Thanks a lot.
    Flavio Matiello

    The way global variables could be created using java classes is by using static variables.The class variable values are stored in the JVM's memory
    In Oracle8i Each session gets its own JVM & hence you cannot have a Java class variable which could
    span across sessions.
    Hope this helps

  • How to open external files in a Java stored procedure?

    Hi y'all,
    I'm trying to open an external text file from a Java stored procedure. The java sp has been successfully loaded, resolved, published, etc. in Oracle. I'm using the following statement to try to open the file (enclosed in a try/catch block):
    BufferedReader fileObj = new BufferedReader(new FileReader("fileName.txt"));
    I'm getting a file not found error. Where is Oracle looking (i.e., what directory)?
    Your help is greatly appreciated,
    Gary

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Gary Nool ([email protected]):
    Hi y'all,
    I'm trying to open an external text file from a Java stored procedure. The java sp has been successfully loaded, resolved, published, etc. in Oracle. I'm using the following statement to try to open the file (enclosed in a try/catch block):
    BufferedReader fileObj = new BufferedReader(new FileReader("fileName.txt"));
    I'm getting a file not found error. Where is Oracle looking (i.e., what directory)?
    Your help is greatly appreciated,
    Gary<HR></BLOCKQUOTE>
    Hi Gary,
    you must use a "database directory", e.g:
    SQL>create directory WORKING_DIR as '/home2/common/';
    SQL> select * from all_directories;
    OWNER DIRECTORY_NAME
    DIRECTORY_PATH
    SYS WORKING_DIR
    /home2/common/
    Gert

  • APEX fails with Java stored procedure that creates a JDBC connection

    Hello!
    We are facing a strange problem since we have upgraded from Oracle 10g and Apache to Oracle 11g with Embedded Gateway.
    Here is what we do:
    ** APEXX calls a PL/SQL package function "OPEN_CONNECTION" that wraps a Java stored procedure called "openConnection".*
    FILE_READER_REMOTE_API.openConnection(user, password, host, port, service);
    ** The Java stored procedures "openConnection" opens a JDBC connection to an other database:*
    public class FileReaderRemote {
    private static Connection conn = null;
    private static DefaultContext remoteContext = null;
    public static void openConnection(String user, String password, String host, String port, String service) throws SQLException {
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    java.util.Properties props = new java.util.Properties();
    props.put ("user", user);
    props.put ("password", password);
    //props.put ("database", "//" + host + ":" + port + "/" + service);
    props.put ("database", host + ":" + port + ":" + service);
    props.put("v$session.program", "FileReaderRemote2");
    // Connect to the database
    remoteContext = Oracle.getConnection("jdbc:oracle:thin:", props);
    This procedure used to work fine before the upgrade, but now we see the following:
    * It still works when called directly from TOAD or SQL*Plus, even under the user ANONYMOUS.
    * When called from APEX and the target database is Oracle 11g, it still works.
    * When called from APEX and the target database is Oracle 10g, it takes several minutes and we receive this error:
    *"Socket read timed out"*
    We have tested the following workaround:
    We have created a database link to our own database and called the stored procedure through that database link.
    FILE_READER_REMOTE_API.openConnection*@loopback*(user, password, host, port, service);
    This works, but is not really an option.
    I hope some one of you can explain this strange behaviour to me.
    Best regards,
    Matthias

    You wrote
    "Java stored procedures -- by definition - are stored in the 8i rdbms. !!"
    From the Oracle8i Java Stored Procedures Developer's Guide
    Release 8.1.5
    A64686-01
    "If you create Java class files on the client side, you can use loadjava to upload them into the RDBMS. Alternatively, you can upload Java source files and let the Aurora JVM compile them. In most cases, it is best to compile and debug programs on the client side, then upload the class files for final testing within the RDBMS"
    This means that you can create shared classes that are used on both the client and server side. The source does not need to reside within the server (according to their documentation). Please also note the following from the Oracle8i JDBC Developer's Guide and Reference Release 8.1.5 A64685-01 for using the getConnection() method on the server:
    "If you connect to the database with the DriverManager.getConnection() method, then use the connect string jdbc:oracle:kprb:. For example:
    DriverManager.getConnection("jdbc:oracle:kprb:");
    Note that you could include a user name and password in the string, but because you are connecting from the server, they would be ignored."
    So if you're coding a shared class that is to run on both the client and server side, you might do something like this:
    Connection conn =
    DriverManager.getConnection(
    System.getProperty("oracle.server.version") == null
    ? "jdbc:oracle:thin:@hostname:1521:ORCL"
    : "jdbc:oracle:kprb:"),
    "youruserid","yourpassword");
    As stated earlier, the userid and password are supposedly ignored for server connections retrieved in this manner. I haven't tried this yet, but it is documented by Oracle.
    Regards,
    Steve
    null

  • How to Store the result sets of a stored procedure that is returning more that one result set in two different table ?

    Hi Experts,
       I have on stored procedure which returns mote than one resultset i want that to store in two different temp table how can achieve this in SQL server.
     following is the stored procedure and table that i need to create.
    create procedure GetData as begin select * from Empselect * from Deptend 
    create table #tmp1 (Ddeptid int, deptname varchar(500),Location varchar(100))
    Insert into #tmp1 (Ddeptid , deptname ,Location )
    exec GetData
    create table #tmp (empid int , ename varchar(500),DeptId int , salary int)
    Insert into #tmp (empId,ename,deptId,salary)
    exec GetData
    Niraj Sevalkar

    You cant get two resultsets out of SP like this. The workaround is to merge and bring the resultsets.
    For this number of columns as well as corresponding datatypes have to be compatible. Also you will need one additional column which indicates resultset value. Then use this as filter to get your desired resultset out
    create procedure GetData as
    begin
    select 'resultset1' as Cat,*,.. N columns from Emp
    union all
    select 'resultset2' as Cat,*,.. N columns from Dept
    end
    create table #tmp1 (Ddeptid int, deptname varchar(500),Location varchar(100))
    Insert into #tmp1 (Ddeptid , deptname ,Location )
    Select column1,column2,column3
    from OPENROWSET('SQLOLEDB','Data Source=Server_name;Trusted_Connection=yes;
    Integrated Security=SSPI','Execute yourdb..GetData')
    WHERE Cat = 'resultset1'
    create table #tmp (empid int , ename varchar(500),DeptId int , salary int)
    Insert into #tmp (empId,ename,deptId,salary)
    Select column1,column2,column3, column4
    from OPENROWSET('SQLOLEDB','Data Source=Server_name;Trusted_Connection=yes;
    Integrated Security=SSPI','Execute yourdb..GetData')
    WHERE Cat = 'resultset2'
    also see
    http://sqlblogcasts.com/blogs/madhivanan/archive/2007/11/26/select-columns-from-exec-procedure-name-is-this-possible.aspx
    Another method is to populate table with relevant resultset within procedure itself and then select from the table directly outside.
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Call Specs for Java Classes

    I have loaded some interdependent java classes in Oracle
    successfully, Not sure about how to write call specs for
    these as one method of class A needs an object of class B as
    input parameter.
    TIA
    PM

    A silly thought just occurred to me. Wouldn't it be
    great to have a dictionary of baby names for java
    classes? I sometimes have a hard time coming up with
    a name for a new class. You know, something other
    r than Foo. Be great if I could just look up some
    suggestions for the kind of thing I'm doing...okay
    back to work.What? I'd rather have a name which is related to what the class does. It doesn't make sense to call e.g. a Date class Jim.
    Kaj - not a class

  • 21700 while calling java stored procedure in 9i

    I create a java stored procedure that takes a varray of a rowtype. When I call that procedure, I get an ora-21700. If I remove the varray from the parameter list, I can call the procedure okay. My goal is to create a generic java procedure that can take a rowtype from any table and create XML. Once I get the oracle.sql.ARRAY into my code, I am okay. I just can't seem to pass it in. I have pasted my code below:
    Java:
    import oracle.sql.*;
    public class test {
    public static String sayHello() {
    return("Hello, World!");
    public static void genXML(oracle.sql.ARRAY a, oracle.sql.CLOB c) throws Exce
    ption {
    c.putString(1,"<test>This is a test!</test>");
    PL/SQL:
    create or replace package mike is
    type dummy_record is varray (1) of dummy%rowtype;
    PROCEDURE GENERATE_XML(i dummy_record, c CLOB);
    FUNCTION SAYHELLO RETURN varchar2;
    end mike;
    show errors
    create or replace package body mike is
    PROCEDURE GENERATE_XML(i dummy_record,c CLOB)
    AS LANGUAGE JAVA
    NAME 'test.genXML(oracle.sql.ARRAY,oracle.sql.CLOB)';
    FUNCTION SAYHELLO RETURN varchar2
    AS LANGUAGE JAVA
    NAME 'test.sayHello() return java.lang.String';
    end mike;
    show errors
    DDL:
    SQL> describe dummy
    Name Null? Type
    USERNAME VARCHAR2(20)
    ID NUMBER
    Test Script:
    declare
    m Mike.dummy_record := Mike.DUMMY_RECORD();
    c CLOB;
    begin
    m.extend;
    select xml into c from t_clob;
    for rec in (select * from dummy)
    LOOP
    m(1) :=rec;
    mike.generate_xml(m,c);
    end loop;
    end;
    And finally, the output:
    declare
    ERROR at line 1:
    ORA-21700: object does not exist or is marked for delete
    ORA-06512: at "MMANGINO.MIKE", line 0
    ORA-06512: at line 10
    Sorry this post is so long, but I wanted it to be complete!
    Mike

    The first solution is to not do that in java in the first place.
    DDL should be in script files which are applied to oracle outside of java.
    Other than I believe there are some existing stored procedures in Oracle that take DDL strings and process them. Your user has to have permission of course. You can track them down via the documentation.

  • 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 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 :)

  • How to wrap a stored procedure that outputs PL/SQL records for JDBC?

    Hello everybody,
    Is there an example for wrapping a stored procedure that outputs PL/SQL records and/or PL/SQL tables of records, so that it can be called from JDBC?
    Since this is not possible with the Oracle JDBC driver, Oracle recommends "To wrap a stored procedure that uses PL/SQL tables, break the data into components or perhaps use Oracle collection types." (http://download-west.oracle.com/docs/cd/B12037_01/java.101/b10979/ref.htm#sthref2123)
    Many thanks for any help,
    Cheers, Christoph

    Hi Christoph,
    Have you tried using JPublisher, or -more easily- JDeveloper (Go to your database connection in the "Connections" pane, open the "Packages" node, right click to "Generate Java...").
    These approaches (at minimum, use of jpub) will generate required PL/SQL wrapper code, including SQL Type declarations. Once these are installed in the database, you can invoke the wrapper procedures directly from Java.
    -- Ekkehard

  • Error while executing Java Stored Procedure.

    Hi,
    When I'm trying to execute my java stored procedure i'm getting the following error:
    ORA-29532: Java call terminated by uncaught Java exception: java.lang.ExceptionInInitializerError
    Does anybody has idea why this error comes and how can be resolved.
    Thanks in advance.
    Uday

    Hi Uday,
    My guess is that there is a problem with your java stored procedure that is causing the "ExceptionInInitializer" error to be thrown. According to the javadoc:
    is thrown to indicate that an exception occurred during
    evaluation of a static initializer or
    the initializer for a static variable
    Since I didn't see any of your code in your post, I can't help you much more, I'm afraid. Perhaps if you would provide some more details, I may be able to help you some more. I think the following details would be helpful:
    1. Complete error message and stack trace you are getting.
    2. The section of your java code that you think is causing the problem.
    3. Oracle database version you are using.
    Good Luck,
    Avi.

Maybe you are looking for