Error calling Java in Oracle Stored Procedure

I can call a java function inside my Oracle Stored Procedure, but if I reference a class that uses JNI, I get problems. I don't know what forum to post this under. This seems the closest match.
Here is my error:
java.lang.NoClassDefFoundError
at AcmeComp.ec.Motor.<init>(Motor.java:35)
at BBOra.runBB(BBOra:13)
Here is my java class, BBOra.java:
import AcmeComp.ec.*;
class BBOra {
static String strCnt;
BBOra() {}
public static void runBB() {
try {
//Motor class is in AcmeComp.ec package
Motor eng = new Motor();
} catch(Exception e) {
System.out.println("Error: " + e);
public static void runNonBB() {
System.out.println("runNonBB works ok.");
From DOS prompt, I loaded ac222ec.jar (has the AcmeComp.ec package) and BBOra.java files into Oracle:
loadjava -u system/manager -resolve -verbose ac222ec.jar.java
loadjava -u system/manager -resolve -verbose BBOra.java
From SQL Plus, I created 2 stored sprocedures:
CREATE OR REPLACE PROCEDURE runBB
AS LANGUAGE JAVA
NAME 'BBOra.runBB()';
CREATE OR REPLACE PROCEDURE runNonBB
AS LANGUAGE JAVA
NAME 'BBOra.runNonBB()';
From SQL Plus, I gave myself permissions to load libraries, so I can load ac222ecjni.dll, which has all the Native (C++) code I use:
BEGIN
DBMS_JAVA.GRANT_PERMISSION('SYSTEM',
'java.lang.RuntimePermission',
'loadLibrary.*');
END;
From SQL Plus, I set up my output:
set SERVEROUTPUT ON;
CALL dbms_java.set_output(3000);
From SQL Plus, I called my Stored Procedures:
CALL runNonBB();
CALL runBB();
runNonBB() works great, but runBB() gives me the error I listed above. The Motor class that BBOra calls, itself calls a class NMotor, which has a call:
static {
System.loadLibrary("ac222ecjni");
Unfortunately, I don't know the inner workings of the native code. Does "at AcmeComp.ec.Motor.<init>(Motor.java:35)"? mean JServer was able to see the class "Motor", but not instatiate it? Or did it error trying to create the class "NMotor"?
Here's a snippet of Motor:
package AcmeComp.ec;
public class Motor implements IMotor {
public Motor() {
motor = new NMotor();
some functions
private NMotor motor;
Here's a snippet of NMotor:
package AcmeComp.ec;
class NMotor {
NMotor() {
sunjdk = true;
some native method declarations
private boolean sunjdk;
static {
//ac222ecjni.dll has all the Native (C++) code
System.loadLibrary("ac222ecjni");
PLEASE HELP ME FIGURE THIS OUT. IT IS KILLING ME. I can even look into the USER_OBJECTS view in Oracle and see that ALL of the classes from the ac222ec.jar are present and accounted for.

Man, I guess I figured it out myself. Ten Duke dollars to myself. But, for the sake of anyone who may want to know the answer, here it is:
JServer (or Oracle9i JVM in Oracle 9i) does not support JNI. Here is their (weak) reasoning, taken from "Oracle9i Java Developer's Guide" as found in http://www.csis.gvsu.edu/GeneralInfo/Oracle/java.920/a96656/invokeap.htm#1007948
"Oracle does not support the use of JNI in Oracle9i Java applications. If you use JNI, your application is not 100% pure Java, and the native methods require porting between platforms. Native methods have the potential for crashing the server, violating security, and corrupting data."
Sounds like a fancy way to say they have a limitation--their JVM isn't up to par all the way. If JNI is a feature in Java, why should Oracle decide for me if I should use it? Don't Java methods also have the potential for crashing the server, violating security, and corrupting data? I think they should just provide the functionality you would expect from a VM and let the user decide which functionality to use. In my case, I HAVE to use JNI, so I'd have to use RMI so that a different VM can do the JNI part.
Sounds pretty lame of Oracle, but oh well.

Similar Messages

  • Java Class - Oracle Stored Procedure - ABAP Program

    My client asked me to design a Java Class that calls a Oracle stored procedure. I was a Java developer so I can do that part. Now this Java Class will be called by a ABAP program. All the data that I got from Oracle Stored Procedure should be retuned to the calling ABAP program.
    In the past I did use JCA and SAP Connectors to get data from SAP R3 by calling BAPI programs.
    I would like to know if the ABAP program uses JCO or the latest JCA based SAP Connectors. Any advice on how I should structure my Java Program is welcome. I do know from pure Java side how to get data from Oracle database using JDBC.

    Hi venkat,
    This link(PDF) gives good info about JCO.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c63bca90-0201-0010-59ae-e0db32750209
    JCO is used as two way communication between JAVA and R/3. so for yours JCO may be the suitable one.
    regards,
    P.Venkat
    Message was edited by: venkataramanan

  • Calling Java Methods from Stored Procedures

    Can I call Java Methods from Oracle Stored Procedures? I have a Java framework that logs events and would like to reuse it for logging events that occur in stored procedures.
    null

    You need to publish java class methods to plsql.
    Attached below is some information.
    Although both PL/SQL modules and Java classes are stored in the database
    and are managed by many of the same mechanisms, each of them resides in
    its own namespace. Therefore, Java methods are not accessible from SQL
    and PL/SQL by default. In order to expose Java methods to the SQL and
    PL/SQL engines, first publish that Java method to the SQL namespace using
    a 'Call Spec'.
    Note: A 'Call Spec' does not create an additional layer of
    execution so there is no performance penalty incurred.
    A 'Call Spec' is simply a syntactical mechanism used to
    make a method known in the SQL namespace.
    The SQL name established by the 'Call Spec' can be top-level or packaged.
    The syntax differs only slightly and is consistent with that used for
    PL/SQL procedures and packages. For more information on the exact
    syntax, see the references listed in 'Related Topics'.
    In general, a top-level procedure 'Call Spec' takes the form:
    CREATE OR REPLACE PROCEDURE procname ( pname mode ptype, ... )
    AS LANGUAGE JAVA NAME 'javaname ( javatype, ... )';
    Where: procname is the SQL name you wish to publish
    pname is the name for a parameter to procname
    mode is the parameter mode (i.e. IN, OUT, IN OUT)
    ptype is a valid SQL type (e.g. NUMBER, CHAR, etc.)
    javaname is the fully qualified name of the Java method
    javatype is a Java type for the corresponding parameter
    Likewise, a top-level function 'Call Spec' takes the form:
    CREATE OR REPLACE FUNCTION fname ( pname mode ptype, ... ) RETURN rtype
    AS LANGUAGE JAVA NAME 'javaname ( javatype, ... ) return javatype';
    Where: fname is the SQL name you wish to publish
    rtype is the SQL return type of the function
    Note: Within the NAME clause, everything within quotes is case
    sensitive. For example, if the keyword 'return' is in all
    CAPS, this Call Spec will not compile.
    Other optional parts of this syntax have been omitted here for simplicity.
    Additional examples in subsequent sections illustrate some of these options.
    eg
    CREATE PROCEDURE MyProc (rowcnt IN NUMBER, numrows OUT NUMBER)
    AS LANGUAGE JAVA NAME 'MyClass.MyMethod(int, int[])';
    There are several important things to note here:
    1.) The 'Call Spec' for a JSP must be created in the same schema as the
    corresponding Java class that implements that method.
    2.) IN parameters are passed by value. This is the only parameter mode
    available in Java. OUT parameters, therefore, must be passed as single
    element arrays in order to emulate pass by reference.
    3.) Parameter names do not need to match, but the number and types of
    the parameters must match (with just one exception - see item 5 below).
    Oracle 8i supports conversions between an assortment of SQL and Java.
    See the references listed in 'Related Topics' for additional information.
    4.) Primitive types (e.g. int, float, etc.) are not required to be fully
    qualified with any package name. However, standard Java object types
    (e.g. String, Integer, etc.) as well as any user defined object types
    (e.g. like those generated by JPublisher) must be prefixed with a
    corresponding package name (e.g. java.lang) if applicable.
    5.) The 'main' method which takes a single String[] parameter can be
    mapped to any PL/SQL procedure or function which takes some number
    of VARCHAR2 or CHAR type IN parameters. For example, the java method:
    public static void main ( String[] args ) { ... }
    can be mapped to each of the following:
    PROCEDURE MyProc2 ( arg1 IN CHAR ) ...
    PROCEDURE MyProc3 ( arg1 IN CHAR, arg2 IN VARCHAR2 ) ...
    PROCEDURE MyProc4 ( arg1 IN VARCHAR2, arg2 IN VARCHAR2 ) ...
    and so forth. Parameters map to the corresponding element of the String
    array (e.g. arg1 -> args[0], arg2 -> args[1], etc.).
    null

  • Call to Oracle stored procedure that returns ref cursor doesn't work

    I'm trying to use an OData service operation with Entity Framework to call an Oracle stored procedure that takes an number as an input parameter and returns a ref cursor. The client is javascript so I'm using the rest console to test my endpoints. I have been able to successful call a regular Oracle stored procedure that takes a number parameter but doesn't return anything so I think I have the different component interactions correct. When I try calling the proc that has an ref cursor for the output I get the following an error "Invalid number or type of parameters". Here are my specifics:
    App.config
    <oracle.dataaccess.client>
    <settings>
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursor.P_RESULTS" value="implicitRefCursor bindinfo='mode=Output'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.0" value="implicitRefCursor metadata='ColumnName=WINDFARM_ID;BaseColumnName=WINDFARM_ID;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Number;ProviderType=Int32'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.1" value="implicitRefCursor metadata='ColumnName=STARTTIME;BaseColumnName=STARTTIME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.2" value="implicitRefCursor metadata='ColumnName=ENDTIME;BaseColumnName=ENDTIME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.3" value="implicitRefCursor metadata='ColumnName=TURBINE_NUMBER;BaseColumnName=TURBINE_NUMBER;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.4" value="implicitRefCursor metadata='ColumnName=NOTES;BaseColumnName=NOTES;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.5" value="implicitRefCursor metadata='ColumnName=TECHNICIAN_NAME;BaseColumnName=TECHNICIAN_NAME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
    <add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYID.RefCursor.P_RESULTS" value="implicitRefCursor bindinfo='mode=Output'" />
    </settings>
    OData Service Operation:
    public class OracleODataService : DataService<OracleEntities>
    // This method is called only once to initialize service-wide policies.
    public static void InitializeService(DataServiceConfiguration config)
    // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
    // Examples:
    config.SetEntitySetAccessRule("*", EntitySetRights.All);
    config.SetServiceOperationAccessRule("GetWorkOrdersByWindfarmId", ServiceOperationRights.All);
    config.SetServiceOperationAccessRule("CreateWorkOrder", ServiceOperationRights.All);
    config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
    [WebGet]
    public IQueryable<GetWorkOrdersByWindfarmId_Result> GetWorkOrdersByWindfarmId(int WindfarmId)
    return this.CurrentDataSource.GetWorkOrdersByWindfarmId(WindfarmId).AsQueryable();
    [WebGet]
    public void CreateWorkOrder(int WindfarmId)
    this.CurrentDataSource.CreateWorkOrder(WindfarmId);
    Here is the stored procedure:
    procedure GetWorkOrdersByWindFarmId(WINDFARMID IN NUMBER,
    P_RESULTS OUT REF_CUR) is
    begin
    OPEN P_RESULTS FOR
    select WINDFARM_ID,
    STARTTIME,
    ENDTIME,
    TURBINE_NUMBER,
    NOTES,
    TECHNICIAN_NAME
    from WORKORDERS
    where WINDFARM_ID = WINDFARMID;
    end GetWorkOrdersByWindFarmId;
    I defined a function import for the stored procedure using the directions I found online by creating a new complex type. I don't know if I should be defining the input parameter, WindfarmId, in my app.config? If I should what would that format look like? I also don't know if I'm invoking the stored procedure correctly in my service operation? I'm testing everything through the rest console because the client consuming this information is written in javascript and expecting a json format. Any help is appreciated!
    Edited by: 1001323 on Apr 20, 2013 8:04 AM
    Edited by: jennyh on Apr 22, 2013 9:00 AM

    Making the change you suggested still resulted in the same Oracle.DataAccess.Client.OracleException {"ORA-06550: line 1, column 8:\nPLS-00306: wrong number or types of arguments in call to 'GETWORKORDERSBYWINDFARMID'\nORA-06550: line 1, column 8:\nPL/SQL: Statement ignored"}     System.Exception {Oracle.DataAccess.Client.OracleException}
    I keep thinking it has to do with my oracle.dataaccess.client settings in App.Config because I don't actually put the WindfarmId and an input parameter. I tried a few different ways to do this but can't find the correct format.

  • Pass xmltype to oracle stored procedure

    I need to pass an xmltype from java to an oracle stored procedure. Does anybody have any sample code to do this? I am using jdeveloper 10.1.2
    Thanks
    MM

    Oracle provides several ways of passing objects to and from java to Oracle Stored Procedure.
    One way is to directly create oracle.sql.STRUCT object and pass array of values to this object. Another way is to implement java.sql.SQLData or oracle.sql.ORAData interfaces in your class and pass this class to setObject function.
    It is all well described in manual in chapter "Working with Oracle Object Types", there is also a lot of examples in this chapter and on the web.
    http://download-uk.oracle.com/docs/cd/B19306_01/java.102/b14355/oraoot.htm - Working with Oracle Object Types
    Some of the examples:
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/ObjectOracleSample/Readme.html
    http://javaalmanac.com/egs/java.sql/InsertObjectOraclePreparedStatement.html

  • Errors in calling Oracle stored procedure using java CallableStatement

    Hello,
    I have an oracle stored procedure below, it has been tested in PL/SQL without errors. During testing, in_c_file_type="F"; out_n_seqno_freeformat=120139596 and out_n_seqno_commaseprated is null (empty in value column).
    When I run the program in Eclipse (windows xp), error messages is below: (It stopped at line 'cstme.execute();' )
    Message:ORA-06550: line 1, column 26: PLS-00103: Encountered the symbol "" when expecting one of the following:   . ( ) , * @ % & | = - + < / > at in is mod remainder not   range rem => .. <an exponent (**)> <> or != or ~= >= <= <>   and or like LIKE2_ LIKE4_ LIKEC_ as between from using ||   indicator multiset member SUBMULTISET_ The symbol ", was inserted before "" to continue. Error code:6550 SQL statement:65000 {code} Does anyone know what cause the error? It seems like something is missing in the stored procedure. But the stored procedure passes the test in the PL/SQL. The oracla driver I used is Oracle thin driver. Oracle version is 10.2.g Thanks in advance. northcloud {code} create or replace procedure SP_GET_SEQNO_2( in_c_file_type in char, out_n_seqno_freeformat out integer, out_n_seqno_commaseprated out integer) is n_seqno_commaseprated    integer; n_seqno_freeformat        integer; begin if in_c_file_type ='F' THEN  SELECT message_counter.nextval INTO n_seqno_freeformat FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_freeformat,empty_clob(),empty_clob()); elsif in_c_file_type ='C' THEN  SELECT message_counter.nextval INTO n_seqno_commaseprated FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_commaseprated,empty_clob(),empty_clob()); else SELECT message_counter.nextval INTO n_seqno_freeformat FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_freeformat,empty_clob(),empty_clob()); SELECT message_counter.nextval INTO n_seqno_commaseprated FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_commaseprated,empty_clob(),empty_clob()); end if; out_n_seqno_freeformat        := n_seqno_freeformat; out_n_seqno_commaseprated    := n_seqno_commaseprated; end SP_GET_SEQNO_2; {code} ----- A part of java code I used to call the stored procedure is here. {code} String escapeString = "{call SP_GET_SEQNO_2 (? ? ?)}"; CallableStatement cstme = null; try { cstme = con.prepareCall(escapeString); cstme.setString(1, "F"); cstme.registerOutParameter(2, java.sql.Types.INTEGER); cstme.registerOutParameter(3, java.sql.Types.INTEGER); cstme.execute(); int seqNoFreeformat=0, seqNocommasepreted=0; seqNoFreeformat = cstme.getInt(2); seqNocommasepreted = cstme.getInt(3); System.out.println ("In ConvertXML.processStoredProcedure(), seqNoFreeformat= "+seqNoFreeformat+";seqNocommasepreted="+seqNocommasepreted); } catch (SQLException e) { //System.out.println ("In ConvertXML.processStoredProcedure(), SQLException: "+e); System.err.println("Message:"+e.getMessage()); System.err.println("Error code:"+e.getErrorCode()); System.err.println("SQL statement:"+e.getSQLState()); log.log(Level.INFO, log.getName() + " - SQLException : "+e); } {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    es5f2000 wrote:
    jschell wrote:
    That works?I dunno. The below definitely works, but like I said, I've only
    ever done it with one output parameter (and that has always
    been a ResultSet).
    String callableQuery = "{?= call my_package.my_call(?, ?)}"
    Yes I have done that and at least in terms of my code it wasn't just a result set.
    But not with two.

  • Problem in calling Oracle stored procedure from Java.

    I am trying to invoke the Oracle stored procedure from Java. The procedure does not take any parameters and does not return anything. If I call it from SQL prompt it is working perfectly. I am calling it in my program as follows.
    callable_stmt=con.prepareCall("{call pkg_name.proc_name()}");
    callable_stmt.execute();
    The problem is the control-of-flow is getting strucked in the second line I wrote. It is not giving any error also.
    Please clarify me what's wrong with my code?
    Seenu.

    And how long does the stored procedure take to run from your client machine when running it via sqlplus?

  • Getting exception whil calling an oracle stored procedure from java program

    Dear All,
    I encounter this error in my application when I call only the stored procedure but the view is executing fine from the application and my environment is as follow:
    Java 1.4
    oracle 10g
    oracle jdbc driver:9.2.0.8.0
    websphere portal 6.0.0.1
    this error is occur from time to time randomly, when it happens, the only workaround is to restart the server..Does anyone have any idea about this error?
    Unable to execute stored Procedure in Method
    java.lang.NullPointerException
    at oracle.jdbc.driver.T4C8Oall.getNumRows(T4C8Oall.java(Compiled Code))
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1140)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java(Compiled Code))
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java(Compiled Code))
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3606)
    at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5267)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecute(WSJdbcPreparedStatement.java:632)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.execute(WSJdbcPreparedStatement.java:427)
    And sometime I am getting this exception
    Unable to execute stored Procedure in Method
    java.lang.ArrayIndexOutOfBoundsException: 27787320
    at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java(Compiled Code))
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1134)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java(Compiled Code))
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java(Compiled Code))
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3606)
    at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:5267)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecute(WSJdbcPreparedStatement.java:632)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.execute(WSJdbcPreparedStatement.java:427)
    Thanks
    Jay

    spacetorrent escribi&oacute;:
    for (int x=0; x <result.size(); x++){
    System.out.println(result.get(x));
    I can't do this, because result object is a Map, and I need write the Key of the Value to obtain.
    So I can do:
    result.get("res");And I odtain a *$Proxy3* Object

  • Oracle stored procedure works in toad but lots of error in java

    I've tested this stored procedure in toad 7.3 and it completes ok.
    I do pass the same IN parameters and OUT parameters.
    I registered the out parameter as a OracleTypes.CURSOR
    if it works in toad or pl/sql, what is wrong? how can this be fixed.
    however, when i execute this in java, this is the exception and garbage i receive:
    java.sql.SQLException: ORA-06550: line 1, column 22:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    := . ( @ % ;
    The symbol "(" was substituted for "" to continue.
    ORA-06550: line 1, column 33:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    . ( ) , * @ % & | = - + < / > at in mod not range rem => ..
    <an exponent (**)> <> or != or ~= >= <= <> and or like
    between is null is not || indicator is
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
    my stored procedure is as follows:
    CREATE OR REPLACE PROCEDURE getUserByLogin (
    arg_subscriptionName IN varchar,
    arg_loginName IN varchar,
    arg_password IN varchar,
    arg_rec_userinfo_valLanguage OUT types.rec_userinfo_valLanguage
    ) AS
    var_userNum int;
    BEGIN
    select
    u.userNum into var_userNum
    from
    userInfo u,
    subscription s
    where
    s.subscriptionName = arg_subscriptionName AND
    s.subscriptionNum = u.subscriptionNum AND
    u.loginName = arg_loginName AND
    u.password = arg_password;
    if (var_userNum is null) then
    var_userNum := 0;
    end if;
    getUser(var_userNum, arg_rec_userinfo_valLanguage);
    END;
    /

    I'm using a callable statement.
    The strange thing is that, when i remove all IN and OUT paramters in the java code and the stored procedure, both the call to the stored procedure and teh execution of the stored procedure works.
    The moment I add in just a IN parameter (in the stored procedure, and setting it in the java code) it stops working, and i receive this error.
    java.sql.SQLException: ORA-06550: line 1, column 23:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    := . ( @ % ;
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
    heres the java code and stored procedure
    CREATE OR REPLACE PROCEDURE sampleProcedure(tax out number)
    is
    BEGIN
    tax := 10 *.15;
    /END;
    CallableStatement statement =conn.prepareCall("{call sampleprocedure ?}");
    statement.registerOutParameter(1,java.sql.Types.INTEGER);
    statement.execute();
    ResultSet rs = statement.getResultSet();
    if((rs = statement.getResultSet()) != null){

  • Calling a java class in my oracle database from a oracle stored procedure

    my oracle stored procedure is:
    create or replace
    PROCEDURE openpdffile
    AS LANGUAGE JAVA
    NAME 'pdfopenbook.mainbook()';
    it is valid and so is this java class;
    import java.sql.*;
    import oracle.jdbc.*;
    public class pdfopenbook //class pdfopen
    public static void mainbook(String args[]) //main function
    try //try statement
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "c:\\temp
    final_book.pdf");
    // Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "sol.exe");
    } catch (Exception e) //catch any exceptions here
    System.out.println("Error" + e ); //print the error
    but i get the error:
    onnecting to the database caprs.
    ORA-29531: no method mainbook in class pdfopenbook
    ORA-06512: at "CAPRS.OPENPDFFILE", line 1
    ORA-06512: at line 2
    Process exited.
    Disconnecting from the database caprs.
    it says there is no mainbook method but there is, what am i doing wrong??
    Thanks,
    Doug

    Pass String[] as an argument to mainbook():
    create or replace PROCEDURE openpdffile
    AS LANGUAGE JAVA
    NAME 'pdfopenbook.mainbook(java.lang.String[])';Have you posted it on the Database forum?
    Regards,
    Nick

  • Error Calling Oracle Stored Procedure From Within Report

    Hi,
    I have a report that calls an oracle stored procedure which returns a ref cursor. The report is working ok in our development environment when called from our development website through .NET.
    When the report is moved and accessed from our UAT website we get the following error :-
    Failed to open a rowset. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for Oracle Description: One or more errors occurred during processing of command. Failed to open a rowset. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for Oracle Description: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'RHS_GET_CAND_SECTION_REFS' ORA-06550: line 1, column 7: PL/SQL: Statement ignored Native Error: Failed to open a rowset. Error in File C:\WINDOWS\TEMP\temp_d663a952-bef6-4bf7-bf1a-5e288afdb612 {9B6DFB38-A436-4940-9D80-B4C23DFFFF19}.rpt: Failed to open a rowset.
    If we open the report manually we are prompted to enter database connection info. If we enter the UAT connection details the report runs ok. If we save the report and try to open it from UAT website through .NET it now opens ok.
    If we then move that same report back to the development environment and open from our development website it fails with the same error above.
    Both connections are using Microsoft OLE DB drivers and the Oracle databases are the same version (10.2.0.1.0).
    Is the connection information being stored in actual report and somehow being used when the report is opened through .NET?
    Any help appreciated
    Regards
    Paul

    Hi,
    Please let me know if the issue occurs with the crystal reports designer, if you are facing issues with the .NET application then a need to create a post [here|SAP Crystal Reports, version for Visual Studio;.
    Regards,
    Hitesh

  • Calling a java class from an oracle stored procedure

    my oracle stored procedure is:
    create or replace
    PROCEDURE openpdffile
    AS LANGUAGE JAVA
    NAME 'pdfopenbook.mainbook()';
    it is valid and so is this java class;
    import java.sql.*;
    import oracle.jdbc.*;
    public class pdfopenbook //class pdfopen
    public static void mainbook(String args[]) //main function
    try //try statement
    Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "c:\\temp\\final_book.pdf");
    // Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "sol.exe");
    } catch (Exception e) //catch any exceptions here
    System.out.println("Error" + e ); //print the error
    but i get the error:
    onnecting to the database caprs.
    ORA-29531: no method mainbook in class pdfopenbook
    ORA-06512: at "CAPRS.OPENPDFFILE", line 1
    ORA-06512: at line 2
    Process exited.
    Disconnecting from the database caprs.
    it says there is no mainbook method but there is, what am i doing wrong??
    Thanks,
    Doug

    http://wiki.answers.com/Q/Can_you_call_a_java_function_from_an_oracle_stored_procedure

  • Calling Java programs from Oracle Stored Procedure

    Is it possible to call Java programs from Oracle stored procs? If possible Can this be used to exchange data from other applications? Is there a better method/feature in oracle for doing data exchange with other apps?

    If what you mean by Oracle stored procedures is pl/sql then yes.
    You can create a "wrapper" this way:
    CREATE OR REPLACE FUNCTION xmlXform
    in_mapUrl IN VARCHAR2,
    in_inputUrl IN VARCHAR2
    RETURN VARCHAR2
    AS
    LANGUAGE JAVA NAME
    'com.yourcompany.xml2any.xform(java.lang.String,java.lang.String)
    RETURN java.lang.String';
    Then load the java as:
    loadjava -user youruser/youruserpasswd -resolve -verbose lib/xmlparserv2.jar classes/com/yourcompany/xform.class classes/com/yourcompany/xml2any.class
    The java, given the correct permissions, can do anything java can do including communicate with outside applications.
    Is this the "best" way... depends on what you are trying to accomplish.

  • Oracle Stored Procedure Call

    Hi,
    I have an Oracle Stored Procedure that I must be calling. The procedure takes two IN parameters, and returns a CHAR(1000) string, not via the OUT parameter, but as normal return.
    I have read articles about how to make Procedure Calls with OUT parameters, but didnt find any on my case. I have tried several options but still get parameter binding errors.
    What I am trying right now is this:
    If anyone
    <b>======== code ==============</b>
    SQLParameter[] params = new SQLParameter[2];
    // Construct three objects corresponding to initial values
    Object objMsisdn = new String("9656364550");
    Object objUsername = new String("abc");
    String output;
    // prepare the oracle procedure parameters
    params[0] = new SQLParameter(objMsisdn, Types.VARCHAR, SQLParameter.IN);
    params[1] = new SQLParameter(objUsername, Types.VARCHAR, SQLParameter.IN);
    try{
    output = custDetDB.getCustDetails(params);
    <b>========================================</b>
    Java DB Control:
    <b>========================================</b>
    * @jc:sql statement="{call www_custdet(?,?)}"
    String getCustDetails(SQLParameter[] params) throws SQLException;
    Right now I am getting "Not All Variables Bound Error". I tried to have all IN & OUT parameters sent as SQLParameter before but that didnt work either.
    Any hints?

    Bashar Abdullah wrote:
    Hi,
    > I have an Oracle Stored Procedure that I must be calling. The procedure takes two IN parameters, and returns a CHAR(1000) string, not via the OUT parameter, but as normal return.
    As far as I know, it is impossible for an Oracle
    stored procedure to return anything except
    as output parameters. Show the text of the procedure,
    and tell us what JDBC driver you're using.
    Joe
    I have read articles about how to make Procedure Calls with OUT parameters, but didnt find any on my case. I have tried several options but still get parameter binding errors.
    > What I am trying right now is this:
    If anyone
    > <b>======== code ==============</b>
    > SQLParameter[] params = new SQLParameter[2];
    >
    // Construct three objects corresponding to initial values
    > Object objMsisdn = new String("9656364550");
    > Object objUsername = new String("abc");
    > String output;
    >
    > // prepare the oracle procedure parameters
    > params[0] = new SQLParameter(objMsisdn, Types.VARCHAR, SQLParameter.IN);
    > params[1] = new SQLParameter(objUsername, Types.VARCHAR, SQLParameter.IN);
    >
    try{
    > output = custDetDB.getCustDetails(params);
    > <b>========================================</b>
    > Java DB Control:
    > <b>========================================</b>
    > /**
    > * @jc:sql statement="{call www_custdet(?,?)}"
    > */
    > String getCustDetails(SQLParameter[] params) throws SQLException;
    >
    > Right now I am getting "Not All Variables Bound Error". I tried to have all IN & OUT parameters sent as SQLParameter before but that didnt work either.
    >
    Any hints?

  • Problem with calling a oracle stored procedure

    Hi,
    I am using the following callable statement to invoke a oracle stored procedure/function.
    String myCallableStmt="{?=call IB_DDL.CREATE_DATASET(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
    But I am getting the following errors which do not make sense to me
    Exception in thread "main" java.lang.NullPointerException
         at oracle.jdbc.driver.T4C8Oall.getNumRows(T4C8Oall.java:870)
         at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:956)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1159)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3284)
         at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3389)
         at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4222)
         at org.jtdemo.CreateDataSet.callCreateDatasetProcedure(CreateDataSet.java:246)
         at org.jtdemo.Main.main(Main.java:29)
    Can anyone help me here.
    Thanks in advance
    Kalyan

    May be I have used the word "procedure" loosely. Its infact a oracle function which returns a message of type Varchar2. Hence "{?=.....} here is used for registering the return value from the function. The remaining statement CREATE_DATASET(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?), here the first 14 are input parameters whereas the last one is the OUT parameter of the function. Hope this helps. Anways I am pasting my code below...
    CallableStatement cstmt = null;
              String myCallableStmt="{?=call IB_DDL.CREATE_DATASET(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
              try {
                   System.out.print("Creating DataSet.......\n");
                   cstmt = targetCon.prepareCall(myCallableStmt);
                   cstmt.setObject("USER_ID_IN",this.USER_ID_IN);
                   cstmt.setObject("TABLE_NAME_IN",this.TABLE_NAME_IN);
                   cstmt.setObject("LAYOUT_IN",this.layoutCollection);
                   cstmt.setObject("DATA_TABLESPACE_IN",this.DATA_TABLESPACE_IN);
                   cstmt.setObject("INDEX_TABLESPACE_IN",this.INDEX_TABLESPACE_IN);
                   cstmt.setObject("STRING_POOL_NAME_IN",this.STRING_POOL_NAME_IN);
                   cstmt.setObject("NUMBER_POOL_NAME_IN",this.NUMBER_POOL_NAME_IN);
                   cstmt.setObject("DATE_POOL_NAME_IN",this.DATE_POOL_NAME_IN);
                   cstmt.setObject("LINK_POOL_NAME_IN",this.LINK_POOL_NAME_IN);
                   cstmt.setObject("DATASET_LEVEL_CONSTR_TYPE",this.DATASET_LEVEL_CONSTR_TYPE);
                   cstmt.setObject("DATASET_LEVEL_CONSTR_BODY",this.DATASET_LEVEL_CONSTR_BODY);
                   cstmt.setObject("POOLING_IN",this.POOLING_IN);
                   cstmt.setObject("SEGMENTATION_IN",this.SEGMENTATION_IN);
                   cstmt.setObject("DATASET_PARTITIONING_IN",this.DATASET_PARTITIONING_IN);
                   cstmt.registerOutParameter("DATASET_ID_OUT",OracleTypes.INTEGER);
                   cstmt.registerOutParameter("RETURN_MESSAGE",OracleTypes.VARCHAR);
                   cstmt.execute();
                   String returnMessage = (String)cstmt.getObject("RETURN_MESSAGE");
                   System.out.print(returnMessage);
              }catch(SQLException e) {
                   e.printStackTrace();
              }

Maybe you are looking for

  • My iPod shows up, but doesn't install correctly. Help?

    Alright, 2 days ago I could plug my iPod (5th Generation iPod video, 30gig) into my PC and it would work just fine. Now when I plug it in it won't work. So I tried uninstalling it and then reinstalling it, now in the hardware monitor it shows up with

  • Cancel Split Valuation

    Hi Pl let me know the the procedure for cancellation of the split valuation config  for a material ,for which initially we have maintained the split valuation. thanks in advance Arun

  • Mac OS Leopard 10.5.8 in MacBook White Unibody

    This machine came´s with 10.6.1, but we are trying to replace 60+ older portables and actually have more than 500+ deployed, the company´s software is really an issue and the new Snow doesn´t allow to run certain apps that are "critical" to the compa

  • Word docs won't open in Mavericks

    When I try to open a Word document I receive the following message - "Word cannot open this document. The document might be in use, the document might not be a valid Word document, or the file name might contain invalid characters (for example,\ /)."

  • Cropping my frame n importing my .mpg videos question

    hiii... i just made a frame for my videoo(frame by michael).. but once i import it to premiere, its automatically make the frame i made with black background (inside the frame) so how can i crop it? thxxx... and i found a problem importing mpg videos