Legal Java Stored Procedure method parameters

Hi,
I'm trying to establish whether Java arrays can be returned from Java Stored Procedures. It seems that I can only return single length (i.e. 1) arrays which is highly restrictive.
If I am creating a Java Stored Proc that will be called from pure Stored Proc land, and my JavaSP could raise a number of exceptions I'm avoiding this and instead trying to return an "error status" as a parameter that the caller can query. i.e. I want the "error status" to be an array of (3) strings including a severity, an error number, and a string containing the Java exception.
Is there a way to do this without requiring all my methods to have 3 String[] parameters, one for each part of the error status? Or is there a better way?
regards
--malcolm                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Hi,
You could consider using object types to store your exception information. In that case you will have to use JPublisher to map the sql types to java types. JPublisher enables you to specify and customize the mapping of SQL object types, object reference types, and collection types (VARRAYs or nested tables) to Java classes.
For more info on JPublisher refer : http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96658/toc.htm
For some Java Stored Procedure samples using object types refer to http://otn.oracle.com/sample_code/tech/java/jsp/oracle9ijsp.html

Similar Messages

  • Retrieving a UDT object from a Java Stored Procedure

    I am really having trouble returning a UDT object (AttributeUDT) from a Java stored procedure. I am using Oracle 8.1.6 and JDeveloper 3.2.2. I have successfully used JPublisher to create the Java source code files for my UDT, now I would like to use that in coordination with my Java stored procedure. I've loaded the Java stored procedure into the database using the Deployment option in JDeveloper. However, when it loads the procedure, it translates the 3rd parameter to an OBJECT type, thus making the stored procedure invalid. I can use SQL Navigator to correct the package by changing the OBJECT reference to AttributeUDT (my UDT data type). Unfortunately, my Java stored procedure still does not work. Any help would be greatly appreciated! Thanks in advance for your time!
    In the example below, could anyone please tell me:
    1. How do I register the OUT variable for the UDT?
    2. Is it correct to use the casted call to getObject to retrieve my UDT object?
    3. Is it valid to use the UDT data type in the java stored procedure method signature?
    The call to the Java stored procedure:
    OracleCallableStatement cs3 = (OracleCallableStatement)conn.prepareCall( "{ call sandbox.getQualifiersV3( ?, ?, ?) }");
    cs3.registerOutParameter( 1, Types.VARCHAR);
    cs3.registerOutParameter( 2, Types.VARCHAR);
    cs3.registerOutParameter( 3, ???????);
    cs3.execute();
    System.out.println( "ID: " + cs3.getString( 1));
    System.out.println( "Prompt: " + cs3.getString( 2));
    AttributeUDT attributes = (AttributeUDT)cs3.getObject( 3);
    System.out.println( "Table id: " + attributes.getLogicalTableId());
    System.out.println( "Element id: " + attributes.getElementId());
    cs3.close();
    ===========================================
    The Java stored procedure:
    public static void getQualifiersV3( String ids[], String prompts[],
    AttributeUDT attributes[]) throws SQLException {
    OracleConnection conn = (OracleConnection)new OracleDriver().defaultConnection();
    Statement stmt = conn.createStatement();
    OracleResultSet rs = (OracleResultSet)stmt.executeQuery(
    "SELECT * "
    + "FROM VPS_ABOK_QUALIFIERS "
    + "WHERE qualifier_id = 2001");
    rs.next();
    ids[0] = rs.getString( 1);
    prompts[0] = rs.getString( 2);
    attributes[0] = (AttributeUDT)rs.getCustomDatum( 3, AttributeUDT.getFactory());
    rs.close();
    stmt.close();
    null

    Sounds like your C2 REF TYP1 attribute may be null. Unfortunately you neglected to say where in your code the NullPointerException occurs.

  • Calling the Java Method in PL/SQL Java Stored procedure errors out

    Hi,
    I could not find a suitable thread to post my PL/SQL question so iam posting it here.........
    I have written a java class by name XYZ which has a method ABC for which there are 9 arguements being passed and its a VOID method.
    This java class has been loaded into ORACLE using DBMS_JAVA.LOADJAVA pkg, Now this class is being called in the oracle as a JAVA Stored procedure...... When ever im trying to call the procedure it throws the following error
    ORA-29531: no method
    *Cause:    An attempt was made to execute a non-existent method in a
    Java class.
    *Action:   Adjust the call or create the specified method.
    The code snippet as follows
    JAVA CODE:
    Class xyz
    public static void Abc (String hostName,
    int port,
    String serviceURL,
    String soapAction,
    int timeOut,
    String wsUser,
    String wsPasWd,
    String keyStore,
    String keyStorePasWd)
    //method implementation
    JAVA STORED PROCEDURE:
    create OR REPLACE procedure ABC_JAVA_SP_CALL
    (p_hostname in varchar2, p_port in number, p_serviceurl in varchar2, p_soapaction in varchar2, p_timeout in number, p_wsuser in varchar2, p_wspasswd in varchar2, p_ks_path in varchar2, p_ks_passwd in varchar2)
    as
    language java
    name 'xyz.Abc(java.lang.String, int, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String)';
    When i try to call
    declare
    p_hostname varchar2(100);
    p_port number;
    p_serviceurl varchar2(100);
    p_soapaction varchar2(100);
    p_timeout number;
    p_wsuser varchar2(100);
    p_wspasswd varchar2(100);
    p_ks_path varchar2(100);
    p_ks_passwd varchar2(100);
    begin
    //SP which returns the values for the required parameters.
    comppkg.getvcsinfo(
    p_hostname,
    p_port ,
    p_serviceurl,
    p_soapaction,
    p_timeout,
    p_wsuser,
    p_wspasswd,
    p_ks_path,
    p_ks_passwd
    Layer7_icengc_ws_tes(p_hostname,
    p_port ,
    p_serviceurl,
    p_soapaction,
    p_timeout,
    p_wsuser,
    p_wspasswd,
    p_ks_path,
    p_ks_passwd);
    end;
    This thing ends up with
    29531. 00000 - "no method %s in class %s"
    *Cause:    An attempt was made to execute a non-existent method in a
    Java class.
    *Action:   Adjust the call or create the specified method.
    Im not understanding what wrong am i doing
    pls help
    Edited by: madhusudan on Feb 12, 2013 8:07 PM

    Hello,
    there is the forum {forum:id=65} for questions about using Java within Oracle.
    Regards
    Marcus
    Edited by: Marwim on 13.02.2013 07:56
    I could not find a suitable thread to post my PL/SQL question so iam posting it here.........You got the hint to the correct forum alread in another thread {message:id=10837976}
    And if you think this is not related to Java but PL/SQL, then you should ask in {forum:id=75}

  • No method found error when calling java stored procedured

    hi:
    i am rather confused about this. i have written several
    java stored procedures and all of them work fine. but when i tried another one , the error message 'no method found 'occurs
    when i call the procedure from sqlplus.
    it' s a simple procedure . but it's very strange and happens
    from time to time
    my compile shell as following
    javac -classpath $ORACLE_HOME/jdbc/lib/classes12.zip GenFiles.java
    $ORACLE_HOME/bin/loadjava -u zw/zw@aixtest GenFiles.class
    and
    my definition as following
    create or replace procedure files(chargeCyckeID varchar2, cycleStart varchar2,cycleEnd varchar2,
    loginName varchar2, filePath varchar2, start1 number, end1 number, step number)
    AS LANGUAGE JAVA
    NAME 'GenFiles.genFile(String , String , String , String , String , int , int , int )';
    and my java code is here :
    import java.sql.*;
    import java.io.*;
    import oracle.jdbc.driver.*;
    public class GenFiles{
         public static void main(String[] args){
              04UU<F7QV\FZ#,V\FZ?*J<#,V\FZ=aJx#,5GB<C{#, ND<~B7>6#,Pr:E?*J<#,Pr:E=aJx#,2=3$#(Iz3IND<~5D<GB<J}#)
         public static void genFile(String chargeCycleID, String cycleStart, String cycleEnd, String loginName, String filePath, int start, int end, int step){
         try{
              String sqllist = "select customer_id,contract_code,     usercode,ani,ord,"
                        + " agent_code,linkman, customer_name , postcode,paymethod_category_id ,"
                        + " ltrim(to_char(cost,'999999990.99')) cost,call_duration,from listani_file where ord> ? and ord<? order by contract_code";
              String sqlcalls1 = "select a.ani || ',' || a.PASS || ',' || to_char(a.START_TIME,'yyyy-mm-dd hh24:mi:ss') stime || ',' || trunc(a.CALL_DURATION/60)||':'||ltrim(to_char(mod(a.CALL_DURATION,60),'09')) CALL_DURATION || ',' || ltrim(to_char((CALL_AMOUNT/ceil(CALL_DURATION/60)),'999999990.99')) RATE || ',' || ltrim(to_char(a.CALL_AMOUNT,'999999990.99')) CALL_AMOUNT"
                        +" from call_fact_mind a "
                        +" where a.usercode=?"
                        + " and a.ani=? "
                        + " and a.period_key<='" + end + "'"
                        + " and a.period_key>='" + start + "'"
                        + " and a.charge_flag='Y' "
                        + " and a.CALL_DURATION>6"
                        + " and a.CALL_AMOUNT>0"
                        +" order by a.period_key";                    
              String sqlcalls2 = "select a.ani || ',' || a.PASS || ',' || to_char(a.START_TIME,'yyyy-mm-dd hh24:mi:ss') stime || ',' || trunc(a.CALL_DURATION/60)||':'||ltrim(to_char(mod(a.CALL_DURATION,60),'09')) CALL_DURATION || ',' || ltrim(to_char((CALL_AMOUNT/ceil(CALL_DURATION/60)),'999999990.99')) RATE || ',' || ltrim(to_char(a.CALL_AMOUNT,'999999990.99')) CALL_AMOUNT "
                        + " from call_fact_mind a "
                        + " where a.usercode=?"
                        + " and a.period_key<='" + end + "'"
                        + " and a.period_key>='" + start + "'"
                        + " and a.charge_flag='Y' "
                        + " and a.CALL_DURATION>6"
                        + " and a.CALL_AMOUNT>0"
                        +" order by a.period_key";                    
              Connection con = new OracleDriver().defaultConnection();
              try{
                   int i = start;
                   //8y>]2=3$Q-;7
                   while( true){
                        if( i>=end ) break;
                        genFile(con, i , i+step, chargeCycleID, loginName, filePath, sqllist, sqlcalls1, sqlcalls2);
                        i += step;
              }catch(Exception ex){
              }finally{
                   if( con != null) con.close();
         }catch(Exception exx){}
              8y>]2=3$Iz3IND<~
         private static void genFile(Connection con, int start, int end, String chargeCycleID, String loginName, String filePath, String sqllist, String sqlcalls1, String sqlcalls2) throws Exception{
              PreparedStatement ps1 = null;
              PreparedStatement ps2 = null;
              PreparedStatement ps3 = null;
              ResultSet rs1 = null;
              ResultSet rs2 = null;
              String fileName = filePath + System.getProperty("file.separator") + start + "_" + end + ".txt";
              BufferedWriter writer = null;
              try{
                   writer = new BufferedWriter(new FileWriter(fileName));
                   ps1 = con.prepareStatement(sqllist);
                   ps2 = con.prepareStatement(sqlcalls1);
                   ps3 = con.prepareStatement(sqlcalls2);
                   ps1.setInt(1, start);
                   ps1.setInt(2, end);
                   rs1 = ps1.executeQuery();
                   //Iz3Ibuffer,V;SPR;6(<GB<J12EP4HkND<~
                   StringBuffer strBuffer = new StringBuffer();
                   int i =0;
                   //Q-;7:OM,=a9{</
                   String preContractCode = "";
                   String currentContractCode = "";
                   while( rs1.next()){
                        currentContractCode = rs1.getString("contract_code");
                        if( rs1.getString("ani") == null){
                             ps2.setString( 1, rs1.getString("usercode"));
                             rs2 = ps2.executeQuery();
                        }else{
                             ps1.setString(1, rs1.getString("usercode"));
                             ps1.setString(2, rs1.getString("ani"));
                             rs2 = ps1.executeQuery();
                        //Hg9{3vOVPB5D:OM,:E#,<SHk:OM,OnM7,contract_costJG:OM,On7QSC
                        if( ! preContractCode.equals(currentContractCode)){                     
                             //TZG0Cf<SHk?UPP
                             strBuffer.append("\r\n");
                             String contractHead = "\"1\"" + ",\"" + rs1.getString("linkman") + "\",\"" + rs1.getString("customer_name")
                                            + "\",\"" + rs1.getString("contract_code") + "\",\"" + rs1.getString("agent_code")
                                            + "\",\"" + chargeCycleID + "\",\"" + rs1.getString("contract_cost") + "\"";
                             strBuffer.append(contractHead);
                        while( rs2.next()){
                             if( i<1000){
                                  i++;
                                  strBuffer.append("\"2\"" + rs2.getString(1));
                             }else{
                                  String str = strBuffer.toString();
                                  writer.write(str, 0, str.length());
                                  strBuffer = new StringBuffer();
                                  strBuffer.append(rs2.getString(1));
                                  i = 1;
                        //<SHk7QSC:O<F
                        if( rs1.getString("ani") == null){
                             String trail = "\"2\"" + ",\"" + "ani: " + "\",\"" + rs1.getString("ani") + "\",\"" + "Total Amount: " + "\",\"" + rs1.getString("cost") + "\"\r\n";
                             strBuffer.append(trail);
                        }else{
                             String trail = "\"2\"" + ",\"" + "usercode: " + "\",\"" + rs1.getString("usercode") + "\",\"" + "Total Amount: " + "\",\"" + rs1.getString("cost") + "\"\r\n";
                             strBuffer.append(trail);
                        preContractCode = currentContractCode;     
                        writer.close();
                        rs2.close();
              }catch(Exception ex){
              }finally{
                   if( rs1 != null) rs1.close();
                   if( rs2 != null) rs2.close();
                   if( ps1 != null) ps1.close();
                   if( ps2 != null) ps2.close();
    i need your help!
    regards
    daniel wang

    Hi again, Daniel,
    I'm only guessing here, but unless you've made lots of mistakes when
    you copied your code to your post to the forum, your method signatures
    don't match. The definition of "genFile" in your java class is quite
    different to what you wrote in your PL/SQL wrapper.
    Also, you have defined "genFile" to be a private method -- I think it
    needs to be public.
    Also, I think the "main" method doesn't need to be in the "GenFiles"
    class -- perhaps you should remove it.
    Also, I think in your PL/SQL wrapper you need to use fully qualified
    names, so use "java.lang.String" and not just "String".
    Lastly, I think you should use the "-force" and "-resolve" flags
    with the "loadjava" command.
    Good Luck,
    Avi.

  • 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

  • [b]Java Stored Procedure generating ora-932 in Oracle 9i [/b]

    Hi ,
    I have written a Java Stored procedure. And I have written a wrapper function as bellow
    FUNCTION "GENERATE_AC_EXCEL_REPORT_FN"
    ( refCursorCall VARCHAR2, fromDate Date, ToDate Date,
    nsn VARCHAR2, period varchar2, site VARCHAR2,
    vendor VARCHAR2, spotbuyType VARCHAR2, dataType, VARCHAR2 )
    return number
    as LANGUAGE java
    NAME 'accountingExcelReports.excelPrinter( java.lang.String, java.sql.Date, java.sql.Date, java.lang.String,java.lang.String , java.lang.String,
    java.lang.String, java.lang.String , java.lang.String) return int';
    This function returns 1000 upon successful execution.
    This used to execute fine in Oracle 8.1.7.
    We installed Oracle 9i recently.
    Server version is 9.2.0.2.1.
    Jserver version is 9.2.0.2.0 .
    Now The function call works fine for the first time. And When execute it for sencond time in the same Session,
    The program is erring out saying inconsistent data typpes.
    This is happening during passing parameters.
    SQL&gt; select
    2 generate_ac_EXCEL_report_fn('Period', to_date('7-1-2002','MM-DD-YYYY'),
    3 to_date('7-31-2002','MM-DD-YYYY'), NULL,
    4 NULL, NULL, NULL, 'ALL' ,'SPOTBUY') from dual;
    GENERATE_AC_EXCEL_REPORT_FN('PERIOD',TO_DATE('7-1-2002','MM-DD-YYYY'),TO_DATE('7-31-2002','MM-DD-YYY
    1000
    SQL&gt; select
    2 generate_ac_EXCEL_report_fn('Period', to_date('7-1-2002','MM-DD-YYYY'),
    3 to_date('7-31-2002','MM-DD-YYYY'), NULL,
    4 NULL, NULL, NULL, 'ALL' ,'SPOTBUY') from dual;
    select
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected IN Conversion failed
    And upon further testing, i noticed this happens when the dates are passed. If date parameters are nulled out, Then the program executes perfectly any number of times.
    The same program worked fine in Oracle 8.1.6
    Any ideas?
    Please help.
    Thanks,
    Srinivas

    Hi Srinivas,
    you shouldn't be calling conn.close() and its not needed when using Server Side Internal driver. If you are calling conn.close, then .....
    extract from JDBC user guide
    If you do call the close() method, be aware of the following:
    All connection instances obtained through the defaultConnection() method, which actually all reference the same connection object, will be closed and
    unavailable for further use, with state and resource cleanup as appropriate. Executing defaultConnection() afterward would result in a new connection
    object.
    Even though the connection object is closed, the implicit connection to the database will not be closed.
    http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96654/advanc.htm#1001042
    Elango.

  • ResultSet from Java Stored Procedures

    Hi,
    How do I obtain a resultset from a Java Stored Procedure?
    My stored procedure, deployed in Oracle8i, has Database package as sample.Have published setConnection() and getDept() methods.
    Code for Java Stored Procedure:
    package SPPackage;
    import java.sql.*;
    public class StoredProcApplication {
    protected static Connection connection = null;
    protected static Statement stmt = null;
    protected static ResultSet res = null;
    public static void setConnection() throws SQLException {
    connection = new oracle.jdbc.driver.OracleDriver().defaultConnection();
    public static void getDept(Object[] obj) throws SQLException {
    if (connection == null) {
    setConnection();
    if (stmt == null) {
    stmt = connection.createStatement();
    if (res == null) {
    res = stmt.executeQuery("select * from DEPT");
    obj[0] = res;
    Code for TesterApplication :
    package SPPackage;
    import java.sql.*;
    public class TesterApplication {
    private static final String URL = "jdbc:oracle:thin:@sandeep:1521:oracle8i";
    private static final String userId = "sandeep";
    private static final String password = "sandeep";
    private Connection connection;
    private CallableStatement stmt;
    private ResultSet res;
    public void setConnection() throws ClassNotFoundException,SQLException {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    connection = DriverManager.getConnection(URL,userId,password);
    public void getResultFromSP() throws SQLException {
    //prepare to call the stored procedure
    stmt = connection.prepareCall("{call sample.getDept(?)}");
    //register the OUT parameters
    stmt.registerOutParameter(1,Types.OTHER);
    //execute the query
    stmt.execute();
    ResultSet res = (ResultSet)stmt.getObject(1);
    while (res.next()) {
    System.out.print(res.getInt(1) + " | " );
    System.out.print(res.getString(2) + " | " );
    System.out.print(res.getString(3) + " \n " );
    public TesterApplication() throws SQLException,ClassNotFoundException {
    try {
    setConnection();
    getResultFromSP();
    } finally {
    if (res != null) { res.close(); res = null; }
    if (stmt != null) { stmt.close(); stmt = null; }
    if (connection != null) { connection.close(); connection = null; }
    public static void main(String[] args) {
    try {
    TesterApplication ta = new TesterApplication();
    } catch (Exception e) {
    System.err.println("Error while executing stored procedure " + e.getMessage());
    e.printStackTrace();
    When I run the TesterApplication, I get the following exception :
    java.sql.SQLException: Invalid column type: get_internal_type
    at oracle.jdbc.dbaccess.DBError.check_error(Compiled Code)
    at oracle.jdbc.driver.OracleStatement.get_internal_type(Compiled Code)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(Compiled Code)
    Also, if I want to execute the ResultSet in the stored proc itself, and return the values as Arrays of int[], and String[], how do I do it?By default the you can populate only int[0], String[0] , i.e. only one value!!!
    if my statement is unknown, i.e, it might return a combination of updates and resultsets, how do I go about processing the result?
    Please advise!!
    TIA
    Sandeep
    null

    Hi kkirk,
    I found the post you mentioned.Well it dates back to November 1999 - "Problem returning resultset or ARRAY from java stored proc" by Stuart Popejoy ([email protected]).Too bad, it is still not solved!!
    I am not very good at PL/SQL.However, it would still be helpful, if you could post the code here, or at my email address.
    Meanwhile, I was trying this during the week-end.There seems to be a glimmer of hope!!
    Let me know, if this makes sense :
    CallableStatement cs = connection.prepareCall("begin open ? for select * from dept; end");
    try {
    cs.registerOutParameter(1,OracleTypes.CURSOR);
    ResultSet res = ((OracleCallableStatement)cs).getCursor(1);
    while (res.next()) {
    //get the values
    } catch (Exception e) {
    e.printStacktrace();
    However, I am getting an exception trace
    Error while executing stored procedure Invalid column type: getLong
    java.sql.SQLException: Invalid column type: getLong
    at oracle.jdbc.dbaccess.DBError.check_error(Compiled Code)
    at oracle.jdbc.driver.OracleStatement.getLongValue(Compiled Code)
    Not quite sure why this is happening!!
    TIA,
    Sandeep
    null

  • Java- Stored Procedure with Call by Result

    Hi Oracle-Community,
    I am looking for some example Code how to use a Java-Stored Procedure with Out-Parameters. Don't get me wrong. I dont want to call a Procedure with Out Parameters from Java (there are a lot of examples for this out there) . I just want to implement the Call by Result concept in a Java-Stored Procedure. A Client will call this Procedure with some parameters and the Java Procedure will fill them. So my first question: is this possible? And my second Question: How to implement it?
    Greetings.

    I found out a solution. It is very simple.
    Just defining the parameters as java array (e.g. String[] P1). The first value (P1[0]) is the returned value.
    At last just set in JDeveloper in the "Edit Method Signature" Dialog the parametermode to OUT.
    The dialog can be found by rightclicking on the stored procedure in the dbexport file. You can read this
    in Section 6 Publishing Java Classes With Call Specifications -> Setting Parameter Modes in
    Oracle Database Java Developer's Guide.

  • Java stored procedure in Oracle 8i

    Hi,
    I read in the whitepaper of Oracle "Stored Procedure Tutorial", I have a little problem understanding the following syntax in the example enclosed, please help.
    In Java environment the method:
    public static void assignEMailAddress(Connection conn, int eno, String fname, String lname) throws Exception;
    this method take 4 parameters, but when it is public to SQL, the parameter is ignored!
    Is this understood by the DBMS?
    Is this Connection-typed parameter must ALWAYS be the first one in the proceudre list or the procedure list can be in any order?
    The tutorial is given in Oracle 8i, Lite, we will be using the real Entreprise Oracle 8i, does it make any difference in how we should load java stored procedure?
    I really appreciate any help. thanks
    null

    Mapping between Java types and pl/sql types
    can only be done for standard Java datatypes.
    You cannot publish a java procedure accepting a Connection variable to PLSQL.
    Hope this helps.

  • 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

  • Oracle stored procedure to Java stored procedure

    Hello,
    I got a school assignement "Create a java stored procedure and call it out from JAVA program outside database".
    I've done it, but in case of JAVA stored procedure I have the procedure written in PL/SQL.
    PL/SQL procedure:
    CREATE OR REPLACE PROCEDURE getDogInfo
    (Dog_ID IN NUMBER, Dog_name OUT VARCHAR) AS
    BEGIN
      SELECT Name INTO Dog_name
      FROM Dog_family
      WHERE ID = Dog_ID;
    END;
    How do I convert it to JAVA stored procedure?
    Maybe it's just plain stupid and I should keep it as PL/SQL? I don't know if I have done it right.
    Also I don't know what to do with IN/OUT parameters in JAVA.

    Could my procedure java class look something like this? I am aware that I have to make a PL/SQL function that is associated with JAVA method CALL, just asking about JAVA Class at the moment.
    import java.sql.*;
    import java.io.*;
    public class Procedure {
      public static void getDogInfo (int Dog_ID, String Dog_name)
        throws SQLException
        { String sql =
          "SELECT Dog_name INTO Name FROM Dog_family WHERE ID = Dog_ID";
        try { Connection conn = DriverManager.getConnection("jdbc:default:connection:");
          PreparedStatement apstmt = conn.prepareStatement(sql);
          apstmt.setInt(1, Dog_ID);
          apstmt.registerOutParameter(2, java.sql.Types.VARCHAR);
          ResultSet rset = apstmt.executeQuery();
          rset.close();
          apstmt.close(); //Connection close
        catch (SQLException e) {System.err.println(e.getMessage());
    My java program looks like this:
    package client;
    import java.sql.*;
    public class JDBCPiemers {
        static final String JDBC_DRIVER = "oracle.jdbc.OracleDriver";
        static final String DB_URL = "jdbc:oracle:thin:@localhost:1521:ORCL";
        static final String USER = "SYSTEM";
        static final String PASS = "asdasd";
        private String sql;
        public static void main(String[] args) throws ClassNotFoundException, SQLException {
            Connection conn = null;
            CallableStatement stmt = null;
            try {
                //Registering JDBC driver
                Class.forName("oracle.jdbc.driver.OracleDriver");
                System.out.println("Connecting to database ...");
                conn = DriverManager.getConnection(DB_URL, USER, PASS);
                System.out.println("Preparing command...");
                String SQL = "{CALL getDogInfo (?, ?)}";
                stmt = conn.prepareCall(SQL);
                int Dog_ID = 4;
                stmt.setInt(1,Dog_ID);
                stmt.registerOutParameter(2, java.sql.Types.VARCHAR);
                System.out.println("CALL of JAVA stored procedure ...");
                // Executing SQL
                stmt.execute();
                //Using getXXX method
                String Name = stmt.getString(2);
                System.out.println("Printing results ...");
                System.out.println("ID NR. " +Dog_ID + " is Dog with
    a name  '" + Name + "'" );      
                stmt.close();
                conn.close(); }
                catch(SQLException se) {
                    //JDBC Errors
                    se.printStackTrace(); }
                catch(Exception e) {
                    //Errors Class.forName
                    e.printStackTrace(); }
                finally {
                    //Clossing resurses
                    try {if(stmt!=null)
                    stmt.close(); }
                catch(SQLException se2) {}
                    try {if(conn!=null)
                    conn.close(); }
                    catch(SQLException se) {se.printStackTrace(); }
                    //finally block end
                } // try
                System.out.println("Closing program."); }}

  • Error while executing java stored procedure from a pl/sql procedure

    We have a requirement where we need to execute JAVA code stored in an Oracle database (Java Stored Procedure). This code uses some JAR files which we have already loaded without any errors in the database.
    The class file was also loaded in the database without any errors. But when we execute the method of this class (JAVA code), it gives the following error:
    ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.NoClassDefFoundError
    Is there any way of debugging the code and getting to know where exactly the problem is? Or, any tool/software available for doing the same.
    Any pointers would be of great help!
    Thanks in advance

    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.

  • Executing batch file from Java stored procedure hang

    Dears,
    I'm using the following code to execute batch file from Java Stored procedure, which is working fine from Java IDE JDeveloper 10.1.3.4.
    public static String runFile(String drive)
    String result = "";
    String content = "echo off\n" + "vol " + drive + ": | find /i \"Serial Number is\"";
    try {
    File directory = new File(drive + ":");
    File file = File.createTempFile("bb1", ".bat", directory);
    file.deleteOnExit();
    FileWriter fw = new java.io.FileWriter(file);
    fw.write(content);
    fw.close();
    // The next line is the command causing the problem
    Process p = Runtime.getRuntime().exec("cmd.exe /c " + file.getPath());
    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line;
    while ((line = input.readLine()) != null)
    result += line;
    input.close();
    file.delete();
    result = result.substring( result.lastIndexOf( ' ' )).trim();
    } catch (Exception e) {
    e.printStackTrace();
    result = e.getClass().getName() + " : " + e.getMessage();
    return result;
    The above code is used in getting the volume of a drive on windows, something like "80EC-C230"
    I gave the SYSTEM schema the required privilege to execute the code.
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'java.io.FilePermission', '&lt;&lt;ALL FILES&gt;&gt;', 'read ,write, execute, delete');
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
    EXEC DBMS_JAVA.grant_permission('SYSTEM', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
    GRANT JAVAUSERPRIV TO SYSTEM;
    I have used the following to load the class in Oracle 9ir2 DB:
    loadjava -u [system/******@orcl|mailto:system/******@orcl] -v -resolve C:\Server\src\net\dev\Util.java
    CREATE FUNCTION A1(drive IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'net.dev.Util.a1(java.lang.String) return java.lang.String';
    variable serial1 varchar2(1000);
    call A1( 'C' ) into :serial1;
    The problem that it hangs when I execute the call to the function (I have indicated the line causing the problem in a comment in the code).
    I have seen similar problems on other forums, but no solution posted
    [http://oracle.ittoolbox.com/groups/technical-functional/oracle-jdeveloper-l/run-an-exe-file-using-oracle-database-trigger-1567662]
    I have posted this in JDeveloper forum ([t-853821]) but suggested to post for forum in DB.
    Can anyne help?

    Dear Peter,
    You are totally right, I got this as mistake copy paste. I'm just having a Java utility for running external files outside Oracle DB, this is the method runFile()
    I'm passing it the content of script and names of file to be created on the fly and executed then deleted, sorry for the mistake in creating caller function.
    The main point, how I claim that the line in code where creating external process is the problem. I have tried the code with commenting this line and it was working ok, I made this to make sure of the permission required that I need to give to the schema passing security permission problems.
    The function script is running perfect if I'm executing vbs script outside Oracle using something like "cscript //NoLogo aaa1.vbs", but when I use the command line the call just never returns to me "cmd.exe /c bb1.bat".
    where content of bb1.bat as follows:
    echo off
    vol C: | find /i "Serial Number is"
    The above batch file just get the serial number of hard drive assigned when windows formatted HD.
    Same code runs outside Oracle just fine, but inside Oracle doesn't return if I exectued the following:
    variable serial1 varchar2(1000);
    call A1( 'C' ) into :serial1;
    Never returns
    Thanks for tracing teh issue to that details ;) hope you coul help.

  • Java Stored Procedure using XSU on 9i Lite

    I have create Java Stored Procedure using XML SQL Utility to return results in XML format. I have tested the stored procedure on the development machine (with SDK and Webtogo)without any problem. When I tested it on the client machine (with only the lite database for Window download from the webtogo server as part of the setup), there's an error [POL-8035] no such attribute or method when I call the procedure through MSQL. However, after calling the stored procedure the 3rd times, it will return the results in XML. Once I logout after that, I will have to call the same SP 3 times (always 3 times) before I get the results.
    I'm running on Win2000, Oracle lite 5.0.1. with jdk 1.3.1 - same for the development machine.
    I'm using the same xsu12.jar file.
    What did I miss?

    Nothing?
    No one? No ideias?
    Regards,
    Flavio Matiello

  • Out of memory error when calling a java stored procedure multiple times

    Trying to run a PL/SQL loop calling a java stored procedure, I get the following error:
    "ORA-04030: out of process memory when trying to allocate 262188 byte callheap,ioc_allocate free)"
    (with some other error lines).
    The stored procedure does two major things:
    1) Open a socket to communicate with a server, of which it queries some data.
    2) Use JDBC (with the default DB connection it has, as a stored procedure) to write the results to a table.
    All socket connections, statements, etc. are properly closed and all memory should be garbage collected between each call.
    Can anyone offer an explanation or additional checks to make? I'm quite sure the code isn't causing the problem, since I've tried running it as a stand alone application (outside of Oracle) and didn't have any problems.
    Thanks.

    Hi,
    Verify that the database parameters are set correctly.
    EA

Maybe you are looking for

  • I am getting an error message saying: The itunes library file can not be saved.  You do not have enough access priviliges for this operation.  What does this mean?

    Hi, Looking for some help.  I am getting the following error message on my itunes account: "The itunes library file cannot be saved.  You do not have enough access priviliges for the operation." Does anyone know why this is appearing and how to get r

  • Itunes wont sync

    I currently have a laptop running OS X 10.4.11. Apparently it can't have the newest version of itunes. The lastest version it can update to is 9.2.1. My iphone 5s will not sync. I've authorized the computer, i've tried different usb ports and differe

  • Cannot call member function on object type

    On 8.1.6 I cannot call a member function from SQL in the way described in the manual. The following example is almost copied from the manual: create or replace TYPE foo AS OBJECT (a1 NUMBER, MEMBER FUNCTION getbar RETURN NUMBER); create or replace ty

  • Open and write files

    I have to open a file on the server and then save it, but I can't create a FileInputStream object. I know applets are denied file access on the client machine. So I am trying to open and save it in the same applet diretory. I'm trying to do this: fil

  • Really weird ipod touch problem

    so the day i got my ipod touch i was really careful with it i pretty much kept it in one place all day and night but in the morning a strang mark had appeared on the back of it, kind of dark greyish with little dots, looks almost like a small fingerp