Calling Stored Procedures from JAVA Application

Hi all,
i am using JDeveloper 3.2.2 for creating a DB Application that
uses Oracle8i as DB Server.
One approach of the application is to only use PL/SQL Stored
Procedures to write Data back to the DB.
Some of the stored procedures expect more than 20 parameters.
I want to know if there is a better way to call such a stored
procedure from Java than using a CallableStatement and setting
its 20 parameters.
Another reason why the way above isnt possible for me is that
i need a dynamic way to set the parameters of the stored
procedure.
A solution for that dynamic way i could think of is to get
the information of the stored procedure by using some functions
of DatabaseMetaData and than use this information to map the
parameters with their respective variables in the java
application.
The best argument against this way is that it would be time and
performance consuming.
So could anybody tell me a solution to call PL/SQL stored
procedures from java which is better than doing something like:
String calString = "{Call myStoredProc(";
while(counter < 22) {
params += "?";
if(counter<21) params += ",";
counter++;
calString += params + ")}";
try {
CallableStatement cs = session.prepareCall(calString);
} catch(SQLException ex) { ... }
cs.setString(1, var1);
cs.setString(1, var2);
And that for every Stored Procedure i want to call ?!?
Any help or direction-leading would be really appreciated.
Tank you much.
MfG,
Oliver Bankel

Hi Oliver,
If you your Stored Procedures were in Java and seamlessly
integrated with your Java application would that make your life
easier?
I don't know if this is a practical or acceptable solution in
your environment but it would certainly solve all of your issues
and provide your with a couple of nice advantages. Scalability
and platform independence are just a couple I could think of.
There is a tool called in2j (see http://www.in2j.com) which will
automatically migrate your PL/SQL Stored Procedures into Java.
You can download a copy of the tool and migrate your PL/SQL to
Java with no upfront costs. If you're happy with the generated
Java and want to deploy it, the migration fee falls due - simple.
Hope this helps.
Elton

Similar Messages

  • Error while calling stored procedure from Java

    Hi Guys,
    How are you everybody? I hope everything is goin fine on your side. I have one issue in PL/SQL while calling below stored procedures from Java.
    Problem Description: We have a stored procedure PROCEDURE BULK_INSERTS (
    V_SESSION_ID_TAB IN T_SESSION_ID_TAB_TYPE,
    V_SERVICE_TYPE_TAB IN T_SERVICE_TYPE_TAB_TYPE,
    V_SERVICE_LOCATION_TAB IN T_SERVICE_LOCATION_TAB_TYPE,
    V_SERVICE_CALL_NAME_TAB IN T_SERVICE_CALL_NAME_TAB_TYPE,
    V_SERVICE_CALL_START_TIME_TAB IN T_SERVICE_CALL_ST_TAB_TYPE,
    V_SERVICE_CALL_END_TIME_TAB IN T_SERVICE_CALL_ET_TAB_TYPE,
    V_SERVICE_CALL_DURATION_TAB IN T_SERVICE_CALL_DUR_TAB_TYPE,
    V_STATUS_TAB IN T_STATUS_TAB_TYPE,
    V_NOTES_TAB IN T_NOTES_TAB_TYPE
    ) and we are getting ora errors while calling this stored procedure from java.
    All tab types are declared locally, at package level.
    Here is error which occur while calling this sp:
    {call BULK_PKG.BULK_INSERTS(?,?,?,?,?,?,?,?,?)}
    And the parameter types we are using are:
    SESSION_ID - NUM_TAB_TYPE
    SERVICE_TYPE - VAR_TAB_TYPE
    SERVICE_LOCATION - VAR_TAB_TYPE
    SERVICE_CALL_NAME - VAR_TAB_TYPE
    SERVICE_CALL_START_TIME - DATE_TIME_TAB_TYPE
    SERVICE_CALL_END_TIME - DATE_TIME_TAB_TYPE
    SERVICE_CALL_DURATION - NUM_TAB_TYPE
    STATUS - VAR_TAB_TYPE
    NOTES - VAR_TAB_TYPE
    And the Exception stack trace is:
    ERROR (com.att.retail.r2d2.persistence.dao.ExternalServiceCallDAO.saveExternalServiceCallInfo(ExternalServi
    ceCallDAO.java:143)@ExecuteThread: '252' for queue: 'weblogic.kernel.Default') {Error attempting to save collected ESC data}
    java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'BULK_INSERTS'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1030)
    at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:191)
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:944)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1222)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3381)
    at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3482)
    at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:3856)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:1373)
    at weblogic.jdbc.wrapper.PreparedStatement.execute(PreparedStatement.java:98)
    at com.att.retail.r2d2.persistence.dao.ExternalServiceCallDAO.doBulkInsert(ExternalServiceCallDAO.java:220)
    at com.att.retail.r2d2.persistence.dao.ExternalServiceCallDAO.saveExternalServiceCallInfo(ExternalServiceCallDAO.java:138)
    Please help my guys out of this. I will really appreciate all suggestions and advices.
    Thank you everybody.

    I am trying to pass parameter to test my procedure but it is giving this error : ORA-06531: Reference to uninitialized collection
    ORA-06512: at line 12
    Here is example for my test procedure:
    declare
    v_session_id_tab SESSION_ID_TAB_TYPE;
    v_service_type_tab SERVICE_TYPE_TAB_TYPE ;
    v_service_location_tab SERVICE_LOCATION_TAB_TYPE ;
    v_service_call_name_tab SERVICE_CALL_NAME_TAB_TYPE;
    v_service_call_start_time_tab SERVICE_CALL_ST_TAB_TYPE;
    v_service_call_end_time_tab SERVICE_CALL_ET_TAB_TYPE;
    v_service_call_duration_tab SERVICE_CALL_DUR_TAB_TYPE;
    v_status_tab STATUS_TAB_TYPE;
    v_notes_tab NOTES_TAB_TYPE;
    begin
    v_session_id_tab(1) := 1;
    v_service_type_tab(1) := 'db';
    v_service_location_tab(1) := 'local';
    v_service_call_name_tab(1) := 'Name of call';
    v_service_call_start_time_tab(1) := SYSDATE;
    v_service_call_end_time_tab(1) := SYSDATE;
    v_service_call_duration_tab(1) := 100;
    v_status_tab(1) := 'Z';
    v_notes_tab(1) := 'NOTES';
    BULK_INSERTS (v_session_id_tab,v_service_type_tab, v_service_location_tab,v_service_call_name_tab,v_service_call_start_time_tab,v_service_call_end_time_tab,
    v_service_call_duration_tab, v_status_tab, v_notes_tab);
    end;
    I declare all types at schema level.
    Please give your comments.
    Thank you

  • Calling stored procedure from Java raises ORA-1722 exception

    Hi,
    As the title says, when I call the stored procedure from java I got the exception ORA-1722 (invalid number) but I've checked and rechecked my procedure on SQL-Developer and It's alright it works nice and clean !
    What's happening? is there something I'm missing?
    The way I call the stored procedure is:
        public void execProcedure(String procedure) {
            CallableStatement cs;
            try {
                cs = conn.prepareCall(procedure);
                cs.execute();
            } catch (SQLException ex) {
                Logger.getLogger(Database.class.getName()).log(Level.SEVERE, null, ex);
         where
        String procedure = "{call validateinfo}"I really need help on this, it's frustraiting me 'cause I need to finish a system but this little big problem is killing me ...
    Thanks any advice is very welcome :)

    Thanks for your help. Haven't tested the SP with a DB access client... which one do you recommend to use?
    The SP is the following:
    create or replace
    PROCEDURE validateInfo IS
      var number;
    BEGIN
      UPDATE temp_desarrollo
      SET status = '1';
      COMMIT;
      // Some string validations ...
      //This one just checks if the value of "monto" is a number
      //This update goes good
      UPDATE temp_desarrollo tmp
      SET cve_status = Decode(cve_status, NULL, '15', cve_status||',15')
      WHERE IsNumber(tmp.monto) = 'F';
      COMMIT;*/
      //This one just checks if the value of "monto" is greater than 0
      //if not, change de add to cve_status an errorValue
      UPDATE temp_desarrollo tmp
      SET cve_status = Decode(cve_status, NULL, '14', cve_status||',14')
      WHERE (cve_status NOT LIKE '%15%' OR cve_status IS NULL)
      AND to_number(tmp.monto) <= 0;
      COMMIT;
      //More string validations
      EXCEPTION
        WHEN OTHERS THEN
          var := SQLCODE;
          insert into excepciones values(to_char(var));
    END;I've deleted much code from the SP since I know there's nothing to do with the excepcion, just that UPDATE statement is the one giving me the exception.
    If those two UPDATES statements work with the same field (monto) why the first one is succeding and the second one not?
    Cheers,
    Federico
    P.S. the "isNumber" function is as follows, just in case.
    create or replace
    function IsNumber(val1 varchar2) return varchar2 is
      n number := null;
    begin
      n := to_number(val1,'9999999999999999.99');
        return 'T';
      exception
        when others then
          return 'F';
    end;

  • How to call stored procedures from java program?

    I have tried to run a program that calls a stored procedure on MySQL
    server version 5.0.17 by using connector/j 5.0, but it always fails on the
    statement: con.preparecall() ,
    have looked on the internet and found out that people can all mysql
    stored procedure all right in their programs, really dont know what's
    wrong with this small peiece of code:
    import java.sql.*;
    public class TestDB {
          // procedure being called is:
         CREATE PROCEDURE `dbsaystorm`.`getsite` ()
         BEGIN
            select  name  from tblsite;
         END
         public static void main(String[] args) {
              try  {
                  //Class.forName("org.gjt.mm.mysql.Driver");
                  Class.forName("com.mysql.jdbc.Driver");
                  Connection con = DriverManager.getConnection("jdbc:mysql://localhost/dbname",
                            "user", "pwd");
           * executing SQL statement here gives perfect correct results:
            // PreparedStatement ps = con.prepareStatement("select name from tblsite");      
            // ResultSet rs =ps.executeQuery();
                  // but in stored procedure way...
                  //it fails here on this prepare call statement:             
                  CallableStatement proc = con.prepareCall("call getsite()");
                  ResultSet rs =proc.executeQuery();                      
                  if (rs == null) return;                                      
                  while (rs.next()){                 
                      System.out.println("site name is: "+ rs.getString(1));                                
                  rs.close();
              } catch (SQLException e) {e.printStackTrace();}
               catch (Exception e) {e.printStackTrace();}         
    }it always gives this exception:
    java.lang.NullPointerException
         at com.mysql.jdbc.StringUtils.indexOfIgnoreCaseRespectQuotes(StringUtils.java:959)
         at com.mysql.jdbc.DatabaseMetaData.getCallStmtParameterTypes(DatabaseMetaData.java:1280)
         at com.mysql.jdbc.DatabaseMetaData.getProcedureColumns(DatabaseMetaData.java:3668)
         at com.mysql.jdbc.CallableStatement.determineParameterTypes(CallableStatement.java:638)
         at com.mysql.jdbc.CallableStatement.<init>(CallableStatement.java:453)
         at com.mysql.jdbc.Connection.parseCallableStatement(Connection.java:4365)
         at com.mysql.jdbc.Connection.prepareCall(Connection.java:4439)
         at com.mysql.jdbc.Connection.prepareCall(Connection.java:4413)
         at saystorm.server.data.database.TestDB.main(TestDB.java:29)
    where have I gone wrong?
    when I commented out the statement that makes the procedure call and call preparedstatement to execute SQL select statement, it gave perfectly correct result.
    it looks like there is no problem with java prog accessing MYSQL server database, but the it seems that it's just java can't call stored procedure stored on the mysql server version 5.
    can it or can't it? if it can, how is that accomplished?

    It is a bug in the driver because it shouldn't be
    returning that exception (null pointer) even if you
    are doing something wrong.
    Are you using the latest version of the driver?
    The stored procedure runs when you run it from the
    gui/command line using a MySQL tool - correct?
    As suggested you should be using the brackets. What
    is the data type of the 'name' field?
    You could try returning another value like one of the
    following
    select 1, name from tblsite;
    select name, 1 from tblsite;
    That might get around the bug
    Additionally try just the following...
    select 'test' from tblsite;yes, the driver used is in connector/j 5.0--the lastest one, and the
    procedure can run correctedly at either command line or GUI mode
    with no problem whatsoever, the returned data type is string type,
    I have not got the chance to test it again with those values you
    suggested, as I have abandoned the laptop I used to write that code
    initately. There have been some other really weird cases happened on
    that computer. I guess that must be something wrong with the JVM
    installed on it, it was upgraded from jre5.0.04 to 06, and to 09.
    something within hte JVM must have been messed up(the only reasonable
    explanation). Because the same code runs correctly on my new laptop,
    using the same environment: jvm 5.0_09, mysql 5.0.18, connector/J 5.0.
    that old laptop really was a nightmare.

  • Calling stored procedure from java...

    Hello,
    I've got a stored procedure that works correctly if I call it in Toad like:
    declare
    c CLOB;
    BEGIN
    GETLOCATIONSVOXML (c, '0087890', 8, 2007);
    END;
    no problems there however I'm trying to call it from java..
    public String getDALocations(String inEmplid, Date weekEndDate ) throws Exception {
              Connection connection = null;
              Clob loc;     
              String rtnSt = "";
              SimpleDateFormat yy = new SimpleDateFormat("yyyy");
              SimpleDateFormat ww = new SimpleDateFormat("ww");     
              try     {
                   connection = getConnection();           
                   CallableStatement  cs = connection.prepareCall(SQL_GETDALOCATIONXML);
                   cs.registerOutParameter(1,oracle.jdbc.driver.OracleTypes.CLOB);
                   cs.setString(2, inEmplid);
                   cs.setString(3, ww.format(weekEndDate));          
                   cs.setString(4, yy.format(weekEndDate));               
                   cs.execute();
                   loc = (Clob)cs.getClob(1);
                   rtnSt = "<node label='locations'>" + loc.getSubString(1,(int)loc.length()) + "</node>";
                   cs.close();
                    log.debug("retrieved xml locations");
              catch ( SQLException e ){
                   log.error("LocationDAO.getDALocations() failed", e);
                   throw new Exception(e);
              }     finally     {             
                   releaseConnection(connection);
    return rtnSt;          
    [pre]
    I'm getting the <node label='locations'></node> back, but nothing in between..
    Anyone offer any suggestions or ideas I can try? I'm wondering if the data in Oracle is being read incorrectly.. Is there anyway I can check that?
    Thanks so much!
    Thanks!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    aha! seems to be a problem with my proc...
    select c_schedulestatusid as status
    from schedule_status
    where location = 4131
    and week = 11
    and year = 2007
    [pre]
    part of my proc is returning null.. arg stupid error...                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Calling stored procedures from entity object and application module

    Hello
    I've put in place an EntiyImpl base class containg helper methods to call stored procedures.
    I now need to call stored procedures from the application module.
    Apart from creating an application module base class and duplicating the helper method code is there a way
    to share the helper methods for calling stored procedures between the entity impl and application module impl ?
    Regards
    Paul

    Does the helper code depend on features of a particular entity object instance, beyond its database transaction?
    If so, I'm not sure I see how it could be used from an application module class.
    If not, here's what you do:
    Step 1:
    Parametrize the database transaction--you might even want to. So instead of
    protected myHelperMethod(Object someParam) {
    DBTransaction trans = getDBTransaction();
    change this to
    protected myHelperMethod(DBTransaction trans, Object someParam) {
    Step 2: make the method public and static--once you parameterize the DBTransaction, you should be able to do this.
    public static myHelperMethod(DBTransaction trans, Object someParam) {
    Step 3: Remove the method from your EntityImpl base class into a utility class:
    public abstract class PlSqlUtils {
    private PlSqlUtils() {}
    public static myHelperMethod(DBTransaction trans, Object someParam) {
    When you want to call the method from an application module, entity object, or even view object class, call
    PlSqlUtils.myHelperMethod(getDBTransaction(), paramValue);
    Unlike Transaction.executeCommand(), this lets you provide functionality like setting procedure parameter values, retrieving OUT parameter values, etc.
    Hope this helps,
    Avrom

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

  • Calling packaged stored procedure from Java

    Hi All,
    I'm trying to call a stored procedure from Java but I'm having
    problems with registrating the output parameter. I'm getting
    the error: Conflicting parameters.: sqltype=2003
    This is the stored procedure which is located in a package in
    the Oracle database:
    package Pack_GetAgencyInformation as
    Type InfoType is record ( agen_code varchar(3), agen_designation
    varchar(30), agen_adresse varchar(60), agen_tel varchar(12) );
    function GetAgencyInformation( P_AGENCE VARCHAR )
    return Pack_GetAgencyInformation.InfoType
    end Pack_GetAgencyInformation;
    This is the Java source from where I'm calling the procedure:
    //DriverManager.registerDriver (new
    oracle.jdbc.driver.OracleDriver());
         Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@164.48.69.125:1521:ventes", "system", "*****
    // @machineName:port:SID,
    userid, password
    CallableStatement cs = conn.prepareCall("{ ? = call
    Pack_GetAgencyInformation.GetAgencyInformation( ? )}");
         try {
              cs.registerOutParameter( 1,
    oracle.jdbc.driver.OracleTypes.ARRAY);
         } catch (SQLException e) {
              e.printStackTrace();
         cs.setString(2, "001" );
         //ResultSet rset = cs.executeQuery();
    The stacktrace:
    java.sql.SQLException: Parametertypen conflicteren.:
    sqlType=2003
    at oracle.jdbc.dbaccess.DBError.throwSqlException
    (DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException
    (DBError.java:210)
    at
    oracle.jdbc.driver.OracleCallableStatement.registerOutParameter
    (OracleCallableStatement.java:220)
    at
    oracle.jdbc.driver.OracleCallableStatement.registerOutParameter
    (OracleCallableStatement.java:350)
    at dbAccess.main(dbAccess.java:25)
    I think it has to do with the type InfoType which is created in
    the Stored Procedure. I'm absolute no Oracle expert and I
    prefer not to make changes to the Oracle database. So any
    solution in Java is welcome!
    BR, H.Rietman

    I managed to get it to work only by changing the stored
    procedure. I have changed the return type record to a Ref
    Cursor type (had to change alot of code for this). It seams
    that Oracle JDBC drivers DON'T support the Record type as a
    return type.
    So the next question is: is it possible to typecast a record
    type to a ref cursor type in Oracle. In this way I can easily
    change the return type for the stored procedures.
    /Harald

  • DB2 Stored Procedure from Java-JDBC

    Hi All,
    I am using DB2 stored procedure which have been written in COBOL. I have two types of stored procedures. First types of stored procedure takes IN parameter and returns OUT parameter. These stored procedures are working fine. The second type of stored procedure takes IN parameter and returns a CURSOR. According to Database team (who wrote these stored procedure) claims that they can see data in a cursor when they test these stored procedure directly in the database. However, when I run these stored procedures from Java code it returns NULL ResultSet. Here is the code:
    public SearchResult getAllBenefitHEDType(SearchParameter searchParam) throws DAOException {
    log.debug(" getAllBenefitHEDType method - entering ");
    HashMap searchParametersMap = searchParam.getHashMap();
    SearchResult searchResult = new SearchResult();
    String type = (String) searchParametersMap.get(UDFConstant.LOOKUP_SEARCH_TYPE);
    HashMap resultParametersMap = new HashMap();
    ArrayList resultSetDTO = new ArrayList();
    try {
    conn = this.getConnection();
    conn.setAutoCommit(false);
    System.out.println("getAllBenefitHEDType Step 1");
    CallableStatement cs = conn.prepareCall("{call TEST.APS003(?)}"); // Stored Procedure with one IN parameter.
    cs.setString(1,type);
    boolean retVal = cs.execute(); // this should return true if ResultSet is available.. in my case it is returning false.
    // I tried with getting the Object
    ResultSet rs = (ResultSet) cs.getObject(1); // this should give me a valid result set ... in my case I am getting null
    if (rs!=null) {
    System.out.println("getAllBenefitHEDType Step 4A Result Set Not Null");
    } else {
    System.out.println("getAllBenefitHEDType Step 4A Result Set Is Null");
    // I tried getting the resultset
    ResultSet rs1 = cs.getResultSet(); // this should give me a valid result set ... in my case I am getting null
    if (rs1!=null) {
    System.out.println("getAllBenefitHEDType Step 4D Result Set Not Null");
    } else {
    System.out.println("getAllBenefitHEDType Step 4D Result Set Is Null");
    while (rs.next()) {
    System.out.println("getAllBenefitHEDType Step 5");
    LookupDTO lookupDTO = new LookupDTO();
    // the following code populate the Lookup DTOs from ResultSet.

    A few comments...
    1) Creating tables, particularly tables whose names seem to imply that they are temporary tables, on the fly in a stored procedure is a bad idea. That is not the way to work with Oracle, though it is a common practice in other databases like SQL Server. There is undoubtedly a better way to do this in Oracle if you can explain what you're trying to accomplish from a business standpoint.
    2) If you are going to use dynamic SQL, you almost always want to use bind variables, not literals. One of the quickest ways to kill an Oracle database's performance is to not use bind variables.
    3) As has already been mentioned, assuming FH_INICIO is a DATE column, you need to put an explicit TO_DATE around your strings in order to convert them to dates. Otherwise, Oracle's implicit cast depends on the session's NLS_DATE_FORMAT, which is likely to be different in different client applications and from different client machines.
    Justin

  • How to send a Varying Array param to a PL/SQL Stored Procedure from Java

    * I am VERY new to jdbc, and even somewhat new to Java
    * I'm using Java 1.5, Oracle 10g.
    * I need to call the following PL/SQL Stored Procedure from Java:
    procedure setEventStatus
    i_deQueueStatus in deQueueStatus_type
    *deQueueStatus_type is the following (an array of deQueueStatus_OBJ):
    CREATE OR REPLACE TYPE deQueueStatus_OBJ as object
    eventID number (20),
    dequeuestatus varchar2(20)
    CREATE OR REPLACE TYPE deQueueStatus_TYPE IS VARYING ARRAY(500) of deQueueStatus_obj
    *I have created a Java object as follows:
    public class EventQueueDeQueueStatus
         long      eventID;
         String      dequeueStatus;
         EventQueueDeQueueStatus(long eventID, String dequeueStatus)
              this.eventID = eventID;
              this.dequeueStatus = dequeueStatus;
    I have an ArrayList of these.
    I need to pass this list to the Stored Procedure. How do I create a java.sql.Array so I can call CallableStatement.setArray to set the parameter? Or do I use something else? I have tried setObject with both the ArrayList and also with a primitive array, but got "Invalid Column Type" both times.
    Any help would be greatly appreciated. I just got this task today, and I have to make it work by Tuesday :-( !
    Thanks,
    Kathy

    Kathy,
    Search the archives of this forum and the JDBC forum for the terms STRUCT and ARRAY and you can find some sample code on the JDBC How-To Documents page and the JDBC Samples which can both be accessed from this page:
    http://www.oracle.com/technology/tech/java/sqlj_jdbc/index.html
    Good Luck,
    Avi.

  • Facing error while trying to execute stored procedure from JSF Application

    Hi, I am facing the below error when I try to execute a stored Procedure from JSF application which is deployed on WAS 7.0
    =2013-03-04 19:06:58,550 INFO [com.lloydstsb.iw.util.DBUtils] - DBUtils : executeFileNetStoredProc method started..
    =2013-03-04 19:11:58,271 ERROR [com.lloydstsb.iw.dao.FileNetCustomDBSynchDAOImpl] - Data Access Exception
    com.lloydstsb.iw.common.exceptions.DataAccessException: Data Access Exception Occured : Integration Stored Proc- java.sql.SQLException: java.lang.ClassCastException: oracle.jdbc.driver.LogicalConnection incompatible with oracle.jdbc.OracleConnection
         at com.lloydstsb.iw.util.DBUtils.executeFileNetStoredProc(DBUtils.java:959)
         at com.lloydstsb.iw.util.DAOUtil.executeFileNetStoredProc(DAOUtil.java:117)
         at com.lloydstsb.iw.dao.FileNetCustomDBSynchDAOImpl.updateFileNetDetailsCustomDB(FileNetCustomDBSynchDAOImpl.java:36)
         at com.lloydstsb.iw.servlet.IndexServlet.service(IndexServlet.java:127)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1443)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:790)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:443)
         at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
         at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:91)
         at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:859)
         at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
         at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
         at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
         at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
         at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
         at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
         at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
         at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202)
         at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
         at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896)
         at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
    The oracle version we are using is 11g.
    Previously it worked fine when the application was used in 10g.
    Can someone please help me in resolving this issue?
    Kiran
    Edited by: 991640 on Mar 4, 2013 8:25 PM

    java.lang.ClassCastException: oracle.jdbc.driver.LogicalConnection incompatible with oracle.jdbc.OracleConnection
    Are the the JDBC JARs packaged with the application? If so, remove the applicaiton packaged JDBC JARs as the JARs are also in WebSphere application server.

  • Curious thing while calling a procedure from Java !...

    Hi !. My name is Agustin and my doubt would be the following one... I am working for a e-business comp and they asked me to call a procedure from java... The code is the following one:
    CallableStatement cs = null;
    System.out.println("Fecha Nro. 1: " + paramFechaDesde);
    System.out.println("Fecha Nro. 2: " + paramFechaHasta);
    try
    cs = getDBTransaction().createCallableStatement("{call paq_w_ListadoSiniestralidadART. p_sinsiniest(?,?,?,?) }",0);
    cs.registerOutParameter(4,OracleTypes.VARCHAR);
    cs.setInt(1,paramContrato.intValue());
    cs.setString(2,paramFechaDesde);
    cs.setString(3,paramFechaHasta);
    cs.setString(4,paramNombreArchivo);
    cs.executeQuery();
    String nomArchivo = cs.getString(4);
    System.out.println("### " + nomArchivo +" ###");
    catch(SQLException e)
    The weird thing is that, I was expecting a big big exception but the only thing I got is
    ### Error ###
    The String I am expecting is a file's name !; so I am a little bit confused...
    Also I didn't know where to post so If it's in the wrong category... I apologize !... If anyone need more details, I'll be checking out... The account I am working on is an Insurance company, who is the one who provide access to the DB and the procedures... So I can't check what's inside...

    Please provide your Java and OS versions, the JDBC jar file and the Oracle DB version being used when you post.
    >
    I was expecting a big big exception
    >
    Then why do you have an empty exception block? That just makes it disappear so you won't see one if it happens.
    And your code has
    cs.registerOutParameter(4,OracleTypes.VARCHAR);
    cs.setString(4,paramNombreArchivo);You use 'registerOutParameter' for an OUT parameter and the 'setXXX' methods for other parameters.
    Remove the 'setSTring' for the OUT parameter.
    Then as malcollmmc already said
    >
    Sounds like the PL/SQL is returning "Error" as the 4th parameter of the call
    >
    The actual value returned by PL/SQL is strictly determined by the PL/SQL code and Java and JDBC are not involved.
    Fix the code problems, retest, and folllowup with whoever wrote the code if it still returns ERROR.

  • Calling Stored Procedure from Oracle DataBase using Sender JDBC (JDBC-JMS)

    Hi All,
    We have requirement to move the data from Database to Queue (Interface Flow: JDBC -> JMS).
    Database is Oracle.
    *Based on Event, data will be triggered into two tables: XX & YY. This event occurs twice daily.
    Take one field: 'aa' in XX and compare it with the field: 'pp' in YY.
    If both are equal, then
         if the field: 'qq' in YY table equals to "Add" then take the data from the view table: 'Add_View'.
         else  if the field: 'qq' in YY table equals to "Modify"  then take the data from the view table: 'Modify_View'.
    Finally, We need to archive the selected data from the respective view table.*
    From each table, data will come differently, means with different field names.
    I thought of call Stored Procedure from Sender JDBC Adapter for the above requirement.
    But I heard that, we cannot call stored procedure in Oracle through Sender JDBC as it returns Cursor instead of ResultSet.
    Is there any way other than Stored Procedure?
    How to handle Data Types as data is coming from two different tables?
    Can we create one data type for two tables?
    Is BPM required for this to collect data from two different tables?
    Can somebody guide me on how to handle this?
    Waiting eagerly for help which will be rewarded.
    Thanks and Regards,
    Jyothirmayi.

    Hi Gopal,
    Thank you for your reply.
    >Is there any way other than Stored Procedure?
    Can you try configuring sender adapter to poll the data in intervals. You can configure Automatic TIme planning (ATP) in the sender jdbc channel.
    I need to select the data from different tables based on some conditions. Let me simplify that.
    Suppose Table1 contains 'n' no of rows. For each row, I need to test two conditions where only one condition will be satisfied. If 1st condition is satisfied, then data needs to be taken from Table2 else data needs to be taken from Table3.
    How can we meet this by configuring sender adapter with ATP?
    ================================================================================================
    >How to handle Data Types as data is coming from two different tables?
    If you use join query in the select statement field of the channel then whatever you need select fields will be returned. This might be fields of two tables. your datatype fields are combination of two diff table.
    we need to take data only from one table at a time. It is not join of two tables.
    ================================================================================================
    Thanks,
    Jyothirmayi.

  • Calling stored procedure from EJB in JSever

    I have some trouble to call stored procedure from EJB deployed to JServer on Oracle8i (815).
    I have been able to sucessfully test the stored procedure using thin client JDBC driver. But when I user the default connection in JServer, the stored procedure never got called. Is there any restriction of EJB in JServer?
    Thanks
    null

    Thanks man! that was a great help. looks like i am almost there. i created those items t obe hidden.
    now i am passing three parameters to the procedure. my url for that column value looks like this,
    javascript:P65_PARTITION_ID=#PARTITION_ID#;P65_DBC=#DBC#;P65_FILE_ID=#FILE_ID#;doSubmit('Sku_Save');
    the #DBC# parameter is a name of the person that has spaces(firstname lastname). i am getting a javascript error saying,
    Line: 1
    Char: 37
    Error:Expected ';'
    i see that char 37 is the space after firstname.
    any idea how i should get rid of this error.
    Also, as you have been very helpful, a question further beyond :). the above procedure will return a OUT varchar parameter. i guess i have to create another item for that. how do i read it and display just below my report as text.
    Thanks Again!

  • How to use @jws:sql call Stored Procedure from Workshop

    Is there anyone know how to use @jws tag call Sybase stored procedure within
    Workshop,
    Thanks,

    Anurag,
    Do you know is there any plan to add this feature in future release? and
    when?
    Thanks,
    David
    "Anurag Pareek" <[email protected]> wrote in message
    news:[email protected]..
    David,
    In the current release, we do not support calling stored procedures from a
    database control. You will have to write JDBC code in the JWS file to call
    stored procedures.
    Regards,
    Anurag
    Workshop Support
    "David Yuan" <[email protected]> wrote in message
    news:[email protected]..
    Anurag,
    I know how to use DB connection pool and create a db control with it. In
    fact, we have created a Web Service with the db control using plain SQL
    in
    @jws:sql. However, my question here is how to use @jws tag in Weblogic
    Workshop to create a Web Services based on Sybase stored procedure orany
    Stored Proc not plain SQL.
    Thanks,
    David
    "Anurag Pareek" <[email protected]> wrote in message
    news:[email protected]..
    David,
    You can use a database control to obtain a connection from any JDBC
    Connection Pool configured in the config.xml file. The JDBC Connectionpool
    could be connecting to any database, the database control is
    independent
    of
    that.
    Regards,
    Anurag
    Workshop Support
    "David Yuan" <[email protected]> wrote in message
    news:[email protected]..
    Is there anyone know how to use @jws tag call Sybase stored
    procedure
    within
    Workshop,
    Thanks,

Maybe you are looking for

  • Need help with a Creative AudioPCI (ES1371,ES13

    I have a Creative AudioPCI (ES37,ES373) (WDM) sound card, and I am looking for a copy of its original CD installation. Thanks

  • Firewire drive missing

    Hello My firewire drive is not showing up on left of my window along with the other drives anymore. I have my prefrences set to show hard drives. The internal drive shows up but the fire wire drive does not. The drive is available on the desktop thou

  • Static variable in Formula Node

    Hi, How do I declare and use a static int variable in a formula node?

  • Jsfl and flash components

    Hi, I have been using jsfl to help out with my daily development routines. I just recently wondering if I can have jsfl coded in the custom flash components. I tried to do it, but so far unsuccessful. So I am wondering if this is even possible. I am

  • Problems getting serial number for Lightroom Student and Teacher Edition

    Hello.  I recieved Lightroom 4 Student Edition from a relative last year.  I was in high school at the time, and therefore used my school email address to register the product.  Over the summer the company server went down that maintained the website