CallableStatement problem

hey experts,
I have created one application in JSP and 've used CallableStatement..
but the problem is I am not able to retrieve the correct values from database..
so please let me know where I am going wrong..here's my code::::
Connection con8 = DriverManager.getConnection("jdbc:odbc:JPCData");
CallableStatement stmt8=con8.prepareCall("{CALL count_fish(?,?,?,?,?,?,?)}");
     stmt8.setInt(1,patronid);
     stmt8.setString(2,name);
     stmt8.setString(3,accountno);
     stmt8.setString(4,bankname);
     stmt8.setString(5,ssn);
     stmt8.setString(6,busname);
     stmt8.setString(7,internalcustid);
ResultSet rs8=stmt8.executeQuery();               
while ( rs8.next() ) {
     mdn3=rs8.getInt("a");
I am getting mdn3=0... but if I write the same query in Sql Analyzer it shows me 10 records ..                    
... below is my Store Procedure
CREATE PROCEDURE count_fish
@patcode int,
@patname char(50),
@acctno char(20),
@bankname varchar(100),
@ssn char(15),
@busname char(25),
@intcust char(15)
AS
Select count(*) as a from Account,Patron,BankDetail where (Patron.PatronID not like @patcode) and ((Patron.Name like @patname and Account.AccountNo like @acctno and BankDetail.BankName like @bankname and Patron.SSN like @ssn and Patron.BusName like @busname and Patron.InternalCustID like @intcust) or (Patron.Name like @patname and Account.AccountNo like @acctno and BankDetail.BankName like @bankname and Patron.SSN like @ssn) or (Patron.Name like @patname and Account.AccountNo like @acctno and BankDetail.BankName like @bankname) or (Account.AccountNo like @acctno and BankDetail.BankName like @bankname) or (Account.AccountNo like @acctno or Patron.SSN like @ssn or Patron.Name like @patname )) and (Patron.PatronID=Account.PatronID) and (Patron.PatronID=BankDetail.PatronID)
thanks for ur help
vishu

Hi all,
I figure out that when I am passing integer into Store Procedure then it works fine but it doesn't show me correct result when passing String ..
Can any one give me idea how to pass String using variable...
Let me know is it because I am passing less length than the declared length in Store Procedure??..
say in Store Procedure I have declared name varchar(20) and some times I am passing value to it with some less characters...
thanks guys
please do reply..
Vishu

Similar Messages

  • CallableStatement problem with registering OracleTypes

    Hi all,
    I need to call stored procedure in my java program(see below)
    PROCEDURE GET_SUPPLIER_INFO (P_COMPANY IN, P_supplier_rec OUT DIM_BROKER%ROWTYPE)
    the out parameter is rowtype, but I didn't find proper TYPE for rowtype. I tried cursor, it failed.
    please tell me what is the correct type i need use?
    thanks so much!!

    user591680,
    %ROWTYPE is a [PL/SQL] record type and there is no java mapping for such types in Oracle's JDBC driver.
    You can use an object type instead of a record, or you could use a REF_CURSOR.
    Note that you can also turn your procedure into a function that returns a REF_CURSOR or object and then you wouldn't need an OUT parameter.
    Personally, if your routine only returns a single value, I think a function is better than a procedure with an OUT parameter.
    Good Luck,
    Avi.

  • Problem in using BLOB and callablestatement

    Hi
    I am doing an insert into the database , of which one of the clomn is
    BLOB
    when i do it using prepared statement , it does it fine
    but if i do it using the callable statment (Stored procedure)its not
    doing it .....
    and gives an error like below
    does anybod know what the problem is
    java.sql.SQLException: ORA-06550: line 1, column 9:
    PLS-00306: wrong number or types of arguments in call to 'IN
    SERT_EVENT_LOG'
    ORA-06550: line 1, column 9:
    PL/SQL: Statement ignored
    at weblogic.db.oci.OciCursor.getCDAException(OciCurs
    or.java:228)
    at weblogic.jdbcbase.oci.Statement.executeUpdate(Sta
    tement.java:869)
    at weblogic.jdbc20.pool.PreparedStatement.executeUpd
    ate(PreparedStatement.java:47)
    at weblogic.jdbc20.rmi.internal.PreparedStatementImp
    l.executeUpdate(PreparedStatementImpl.java:54)
    at weblogic.jdbc20.rmi.SerialPreparedStatement.execu
    teUpdate(SerialPreparedStatement.java:55)
    at com.expertcommerce.core.log.DatabaseLogService.in
    ternalLog(DatabaseLogService.java:73)
    at com.expertcommerce.core.log.BaseLogService.log(Ba
    seLogService.java:33)
    at com.expertcommerce.core.log.biz.ServerLogAdapter.
    log(ServerLogAdapter.java:113)
    at com.expertcommerce.core.log.biz.ServerLogAdapter.
    logError(ServerLogAdapter.java:135)
    at com.expertcommerce.core.users.biz.UserEntityBean.
    ejbFindByPrimaryKey(UserEntityBean.java:409)
    at com.expertcommerce.core.users.biz.UserEntityBeanH
    omeImpl.findByPrimaryKey(UserEntityBeanHomeImpl.java:81)
    at com.expertcommerce.core.users.biz.UserEntityBeanH
    omeImpl.findByPrimaryKey(UserEntityBeanHomeImpl.java:49)
    at weblogic.ejb.internal.EJBHomeImpl.remove(EJBHomeI
    mpl.java:297)
    at com.expertcommerce.core.users.biz.UserEntityBeanH
    omeImpl_ServiceStub.remove(UserEntityBeanHomeImpl_ServiceStu
    b.java:378)
    at com.expertcommerce.core.users.biz.UserManagerSess
    ionBean.removeUser(UserManagerSessionBean.java:172)
    at com.expertcommerce.core.users.biz.UserManagerSess
    ionBean.handle(UserManagerSessionBean.java:47)
    at com.expertcommerce.core.users.biz.UserManagerSess
    ionBeanEOImpl.handle(UserManagerSessionBeanEOImpl.java:146)
    at com.expertcommerce.core.users.biz.UserManagerSess
    ionBeanEOImpl_ServiceStub.handle(UserManagerSessionBeanEOImp
    l_ServiceStub.java:255)
    at com.expertcommerce.core.event.CoreEventDispatcher
    .dispatch(CoreEventDispatcher.java:17)
    at com.expertcommerce.core.event.biz.CoreEventDispat
    cherSessionBean.dispatch(CoreEventDispatcherSessionBean.java
    :24)
    at com.expertcommerce.core.event.biz.CoreEventDispat
    cherSessionBeanEOImpl.dispatch(CoreEventDispatcherSessionBea
    nEOImpl.java:105)
    at com.expertcommerce.core.event.biz.CoreEventDispat
    cherSessionBeanEOImpl_WLSkel.invoke(CoreEventDispatcherSessi
    onBeanEOImpl_WLSkel.java:159)
    at weblogic.rmi.extensions.BasicServerObjectAdapter.
    invoke(BasicServerObjectAdapter.java:338)
    at weblogic.rmi.extensions.BasicRequestHandler.handl
    eRequest(BasicRequestHandler.java:69)
    at weblogic.rmi.internal.BasicExecuteRequest.execute
    (BasicExecuteRequest.java:15)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.j
    ava:120)
    com.expertcommerce.core.log.LogServiceException: ORA-06550:
    line 1, column 9:
    PLS-00306: wrong number or types of arguments in call to 'IN
    SERT_EVENT_LOG'
    ORA-06550: line 1, column 9:
    PL/SQL: Statement ignored
    at com.expertcommerce.core.log.DatabaseLogService.in
    ternalLog(DatabaseLogService.java:111)
    at com.expertcommerce.core.log.BaseLogService.log(Ba
    seLogService.java:33)
    at com.expertcommerce.core.log.biz.ServerLogAdapter.
    log(ServerLogAdapter.java:113)
    at com.expertcommerce.core.log.biz.ServerLogAdapter.
    logError(ServerLogAdapter.java:135)
    at com.expertcommerce.core.users.biz.UserEntityBean.
    ejbFindByPrimaryKey(UserEntityBean.java:409)
    at com.expertcommerce.core.users.biz.UserEntityBeanH
    omeImpl.findByPrimaryKey(UserEntityBeanHomeImpl.java:81)
    at com.expertcommerce.core.users.biz.UserEntityBeanH
    omeImpl.findByPrimaryKey(UserEntityBeanHomeImpl.java:49)
    at weblogic.ejb.internal.EJBHomeImpl.remove(EJBHomeI
    mpl.java:297)
    at com.expertcommerce.core.users.biz.UserEntityBeanH
    omeImpl_ServiceStub.remove(UserEntityBeanHomeImpl_ServiceStu
    b.java:378)
    at com.expertcommerce.core.users.biz.UserManagerSess
    ionBean.removeUser(UserManagerSessionBean.java:172)
    at com.expertcommerce.core.users.biz.UserManagerSess
    ionBean.handle(UserManagerSessionBean.java:47)
    at com.expertcommerce.core.users.biz.UserManagerSess
    ionBeanEOImpl.handle(UserManagerSessionBeanEOImpl.java:146)
    at com.expertcommerce.core.users.biz.UserManagerSess
    ionBeanEOImpl_ServiceStub.handle(UserManagerSessionBeanEOImp
    l_ServiceStub.java:255)
    at com.expertcommerce.core.event.CoreEventDispatcher
    .dispatch(CoreEventDispatcher.java:17)
    at com.expertcommerce.core.event.biz.CoreEventDispat
    cherSessionBean.dispatch(CoreEventDispatcherSessionBean.java
    :24)
    at com.expertcommerce.core.event.biz.CoreEventDispat
    cherSessionBeanEOImpl.dispatch(CoreEventDispatcherSessionBea
    nEOImpl.java:105)
    at com.expertcommerce.core.event.biz.CoreEventDispat
    cherSessionBeanEOImpl_WLSkel.invoke(CoreEventDispatcherSessi
    onBeanEOImpl_WLSkel.java:159)
    at weblogic.rmi.extensions.BasicServerObjectAdapter.
    invoke(BasicServerObjectAdapter.java:338)
    at weblogic.rmi.extensions.BasicRequestHandler.handl
    eRequest(BasicRequestHandler.java:69)
    at weblogic.rmi.internal.BasicExecuteRequest.execute
    (BasicExecuteRequest.java:15)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.j
    ava:120)
    with parameter
    exitsfalse
    Retuening result to CoreEventcom.expertcommerce.core.users.e
    vents.RemoveUserEvent@6dcc33
    Stored Procedure .....
    CREATE or replace procedure insert_Event_Log
    pEvent_ID in out number,
    pEvent_Severity in number,
    pEvent_Data in blob,
    pEvent_Action in number,
    pEvent_Time in date,
    pEvent_Source in char,
    pEvent_Status in char,
    pEvent_User in char,
    pEvent_Subject in char,
    pEvent_Subject_ID in char
    AS
    tEvent_ID number;
    BEGIN
    /* Get the sequence key */
    if (pEvent_ID is null ) then
    select event_id_seq.nextval into tEvent_ID from dual;
    insert into Event_ID (pkey, justabit) values ( tEvent_ID, 1);
    end if;
    /* Insert the values in the table */
    INSERT INTO Event_Log
    Event_ID,
    Event_Severity,
    Event_Data,
    Event_Action,
    Event_Time,
    Event_Source,
    Event_Status,
    Event_User,
    Event_Subject,
    Event_Subject_ID
    VALUES (
    tEvent_ID,
    pEvent_Severity,
    pEvent_Data,
    pEvent_Action,
    pEvent_Time,
    pEvent_Source,
    pEvent_Status,
    pEvent_User,
    pEvent_Subject,
    pEvent_Subject_ID
    pEvent_ID := tEvent_ID;
    END;
    My TEst Program
    import java.sql.*;
    import java.util.Properties;
    import oracle.jdbc.driver.*;
    import oracle.sql.*;
    class rfxtest{
    public static void main(String[] args){
    rfxtest test = new rfxtest();
    CallableStatement m_stmt = null;
    PreparedStatement pStmt = null;
    String rfxdata = "this is the test data for the event-blob-test";
    try{
    Connection con = test.getConnection();
    String temp = "call insert_event_log ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
    m_stmt = con.prepareCall(temp);
    m_stmt.setNull(1, java.sql.Types.INTEGER);
    m_stmt.setInt(2, 123);
    m_stmt.setBytes(3, (byte[])rfxdata.getBytes());
    m_stmt.setInt(4, 123);
    m_stmt.setTimestamp(5, new java.sql.Timestamp(System.currentTimeMillis()));
    m_stmt.setString(6, "xxxxxxxxxx");
    m_stmt.setString(7, "xxxxxxxxxx");
    m_stmt.setString(8, "xxxxxxxxxx");
    m_stmt.setString(9, "xxxxxxxxxx");
    m_stmt.setString(10, "xxxxxxxxxx");
    m_stmt.executeUpdate();
    String selectStmt = " select event_data from event_log where event_id = 12345" ;
    pStmt = con.prepareStatement(selectStmt);
    ResultSet rs = pStmt.executeQuery();
    if(!rs.next()){
    System.out.println("error");
    } else {
    Blob b = rs.getBlob(1);
    byte[] blob = (byte[])b.getBytes(1,(int)b.length());
    String s = new String(blob);
    System.out.println("The blob content is : "+s);
    }catch(Exception e){
    e.printStackTrace();
    public Connection getConnection(){
    try{
    Properties props = new Properties();
    props.put("user", "nexgen");
    props.put("password", "nexgen");
    Driver myDriver = (Driver) new oracle.jdbc.driver.OracleDriver();
    Connection conn =
    myDriver.connect("jdbc:oracle:thin:@192.168.254.6:1521:ecw",props);
    return conn;
    catch(Exception e){
    e.printStackTrace();
    return null;
    appreciate response
    venki
    null

    Navid,
    JHeadstart checks whether the attribute definition is queryable before adding it to the list of advanced search attributes. A transient VO attribute can still be set to queryable, for a transient EO attribute this is not possible. We will remove this check on queryability in the upcoming patch release, since you have a valid use case. For now, you can subclass JhsSearchBean and override method createArgumentListForAdvancedSearch and comment out the check for "def.isQueryable()".
    Steven Davelaar,
    JHeadstart Team.

  • Problems with CallableStatements and batch

    Hi,
    I have a for-loop which walk through a Vector and than get data from the current Item of the Vector, put it into the arguments of the CallableStatement and at last add it to batch. When the loop is exiting i execute the batch.
    CallableStatement cstmt = conn.prepareCall("call insertParts(?,?)");
    for (i=0;i<(vec.size());i++)
    PartObject part = (PartObject)vec.get(i);
    cstmt.setInt(1,part.getNumber());
    cstmt.setString(2,part.getName());
    cstmt.addBatch();
    cstmt.executeBatch();My Problem is that only the last PartObject is insert in to the Database, the other PartObjects before are not insert into the Database.
    thx

    // addBatch, executeBatch are not supported by all DB.
    // try execute in the each loop
    CallableStatement cstmt = conn.prepareCall("call insertParts(?,?)");
    for (j=0;i<vec.size();j++)
      PartObject part = (PartObject)vec.get(i);
      cstmt.clearParameters();
      cstmt.setInt(1,part.getNumber());
      cstmt.setString(2,part.getName()); 
      cstmt.executeQuery();
    }  

  • Problem preparing CallableStatement with Weblogic Sybase driver

    I recently switched to using Weblogic's Sybase driver and immediately ran into a problem with some existing JDBC code that ran fine with Sybase's driver. Here is an excerpt of the code:
    String sql = "{call my_sybase_procedure ?,?,?,?,?,?,?,?,?}";
    Connection c = null;
    CallableStatement stmt = null;
    try {     
         stmt = c.prepareCall(sql);
    On the prepareCall method call the following Exception is thrown:
    java.sql.SQLException: [BEA][Sybase JDBC Driver][Sybase]Incorrect syntax near '{'.
    As I said this code runs fine using the Sybase driver com.sybase.jdbc2.jdbc.SybDriver but when I switched to weblogic.jdbc.sybase.SybaseDriver I ran into the problem. I'm using Weblogic Server 8.1 SP4 and the Sybase version is 12.5.
    For now I will revert to using the Sybase driver but if anyone has any insight into this problem I would appreciate the help. Thanks.

    slambert wrote:
    I was looking at the example syntax provided here:
    [url http://java.sun.com/j2se/1.4.2/docs/api/java/sql/CallableStatement.html]http://java.sun.com/j2se/1.4.2/docs/api/java/sql/CallableStatement.html
    It shows square brackets which I interpret as meaning that the parameters are optional. It would have been clearer to me if parentheses were included inside the square brackets.
    Hi. Here's what I get from my JavaSoft doc contacts:
    "For Java SE 6/JDBC 4.0 we corrected it to be:
    {?= call <procedure-name>[(<arg1>,<arg2>, ...)]}
    {call <procedure-name>[(<arg1>,<arg2>, ...)]}
    { call foo} is valid if there are no arguments but you must have
    {call foo(?)|}
    if parameters are passed.
    The javadocs finally now match 13.4.4 of the spec."
    Joe

  • Problem with CallableStatement

    Hello,
    I have a problem with the following code, while trying to execute a sybase stored procedure . The parameters namePar and codePar are strings, which I have hardcoded in the first prepareCall. I don't get data from the database using both of the prepareCall statements, but I have results when I execute the call from the first statement in the database IDE. Do you see anything wrong with this code ?
    Thanks
    sql = dbconn.prepareCall("{call sp_SEARCH_Stocks(21,3, 0, '[][3*]',null, null,'[][8*]',null,null)}");
                sql = dbconn.prepareCall("{call sp_SEARCH_Stocks(? ? ? ? ? ? ? ? ?)}");
                             sql.setInt(1,21);
                             sql.setInt(2,3);
                             sql.setInt(3,0);
                             sql.setString(4,"'[][" + namePar +"*]'");
                             sql.setString(5,null);
                             sql.setString(6,null);
                             sql.setString(7,"'[]["+codePar + "*]'");
                             sql.setString(8,null);
                             sql.setString(9,null);

    The first statement has commas
    The second doesn't.

  • The problem about java.sql.CallableStatement

    we need call oracle store procedure to get a record set.
    the code below is the oracle's pl/sql program for test
    package test2 as
    type sample_record is record(id char(4),
    name varchar2(10),
    addr varchar2(30));
    type sample_cursor is ref cursor return sample_record;
    function get_resultset return sample_cursor;
    end;
    package body test2 as
    function get_resultset return sample_cursor is
    p_cursor sample_cursor;
    begin
    open p_cursor for select 'aaaa' id,'John' name,'guangzhou' addr from dual;
    return p_cursor;
    end get_resultset;
    end;
    and ,in java,how to use java.sql.CallableStatement to
    run the store procedure to get the cursor,a sql type define in our oracle programme

    see the code below,
    public static sun.jdbc.rowset.WebRowSet testmethod(){
         Connection conn = null ;
              CallableStatement cstmt = null ;
              String str = null ;
              ResultSet result = null ;
              str = "{?=call test2.get_resultset()}" ;                    
              try
                   conn = DbPool.getConnection() ;
                   cstmt = conn.prepareCall(str) ;
                   cstmt.registerOutParameter(1, OracleTypes.CURSOR);
                   cstmt.execute();
                   result = (java.sql.ResultSet)cstmt.getObject(1) ;                                             
                   sun.jdbc.rowset.WebRowSet wrs = new sun.jdbc.rowset.WebRowSet() ;
              wrs.populate(result) ;//in this statement,it will throw a NullPointerException
                   return wrs;
              catch (Exception e)
                   CommLog.writeLog("pr", "PrLogic test: " + e.toString()) ;
                   return null ;
              }finally
                   try
                        result.close() ;
                   catch (Exception e3)
                   try
                        cstmt.close() ;
                   catch (Exception e1)
                   try
                        conn.close() ;
                   catch (Exception e2)
         }

  • Unable to execute an update statement using CallableStatement

    Hi there,
    I'm trying to run an update statement from JUnit using java.sql.CallableStatement and oracle.jbo.server.DBTransaction.
            String updateSql =
                "update footable set barcol=TO_DATE('12-SEP-09','dd-MM-yy') where bazcol = 505";
            try {
                statement =
                        applnModule.getDBTransaction().createCallableStatement(updateSql,
                                                                               2);
                int executeUpdate = statement.executeUpdate();
                AppsLogger.write(this,
                                 "# records UPDATED ------------------>" + executeUpdate,
                                 AppsLogger.SEVERE);
            } catch (SQLException s) {
                s.printStackTrace();
                Assert.fail("Encountered SQL Exception: " + s);
            } finally {
                try {
                    if (statement != null)
                        statement.close();
                } catch (SQLException s) {
            }Below is the exception I get when I run the above code. There is no problem with the SQL - it works fine from SQLDeveloper.
    java.lang.AssertionError: Encountered SQL Exception: java.sql.SQLDataException: ORA-01858: a non-numeric character was found where a numeric was expected
         org.junit.Assert.fail(Assert.java:91)
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         java.lang.reflect.Method.invoke(Method.java:597)
         org.junit.internal.runners.TestMethod.invoke(TestMethod.java:66)
         org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:105)
         org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:86)
         org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:94)
         org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:84)
         org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
         oracle.apps.common.applicationsTestFramework.junit.internal.AtfJUnit4JTestCaseClassRunner.invokeTestMethod(AtfJUnit4JTestCaseClassRunner.java:362)
         oracle.apps.common.applicationsTestFramework.junit.internal.AtfJUnit4JTestCaseClassRunner.runMethods(AtfJUnit4JTestCaseClassRunner.java:272)
         oracle.apps.common.applicationsTestFramework.junit.internal.AtfJUnit4JTestCaseClassRunner$1.run(AtfJUnit4JTestCaseClassRunner.java:265)
         org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
         org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
         oracle.apps.common.applicationsTestFramework.junit.internal.AtfJUnit4JTestCaseClassRunner.run(AtfJUnit4JTestCaseClassRunner.java:262)Edited by: 911023 on Oct 2, 2012 11:28 AM
    Edited by: 911023 on Oct 2, 2012 11:30 AM

    Using case statement.
    UPDATE gor_gold_post
       SET hoov_flag = CASE WHEN TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) < 304
                                   OR
                                   (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) IS NULL
                                AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2)
                           THEN 1
                           ELSE 99
                         END,
           b49n      = CASE WHEN TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) < 121.6
                             OR
                             (TRUNC (ADD_MONTHS (rec.loyalty_date, rec.loyalty_period) - SYSDATE) IS NULL
                                AND (SYSDATE - TO_DATE (rec.contract_date, 'YYYYMMDD')) > 91.2)
                           THEN 1
                           ELSE 99
                         END
    WHERE tariff_code IN (169, 135, 136);Note: Code not tested.

  • Problem with setting oracle type parameter in viewobject query

    Hi There,
    I am facing a problem with JDev1013. I have a view that has JDBC positional parameters that are supposed to be in parameters for function like:
    SELECT x.day, x.special_exact_period_only
    FROM (
      SELECT x.day, x.special_exact_period_only
      FROM (
        SELECT
          x.day,
          rb.special_exact_period_only
      FROM TABLE (
        RentabilityPkg.findMarkerSlots(
          'start',
          ? /* dchannel */,
          NULL,
          ? /* resorts */,
          'special',
          NULL,
          ? /* code */,
          NULL,
          TRUNC(SYSDATE),
          TRUNC(SYSDATE + 365 * 2),
          NULL
      ) x
        JOIN resourcebase rb USING (rentabilitymanager_id)
        UNION
        SELECT
          x.day,
          rb.special_exact_period_only
        FROM TABLE (
          RentabilityPkg.findMarkerSlots(
            'start',
            ? /* dchannel */,
            NULL,
            ? /* resorts */,
            'composition',
            NULL,
            ? /* code */,
            NULL,
            TRUNC(SYSDATE),
            TRUNC(SYSDATE + 365 * 2),
            NULL
        ) x
        JOIN resourcebase rb USING (rentabilitymanager_id)
      )x
      ORDER BY x.day
    ) x
    WHERE ROWNUM <= 30now the JDBC positional parameters take our custom defined list type defined as:
    CREATE TYPE NumberList AS TABLE OF NUMBER;
    we are setting the parameter in the views with the help of oracle.sql.ARRAY class like:
       * Set parameters.
      public void setParams(Integer dchannelId, Integer[] resorts, String specialCode)
        try {
              System.out.println(this.getClass() + ".setParams()");
              ARRAY arrParam1 = ((NWSApplicationModule)getApplicationModule()).toSQLNumberList(Arrays.asList(resorts));
              ARRAY arrParam2 = ((NWSApplicationModule)getApplicationModule()).toSQLNumberList(Arrays.asList(resorts));
              System.out.println("arrParam1 - " + arrParam1);
              System.out.println("arrParam1 - " + arrParam1);
              System.out.println(this.getClass() + " ARRAY - " + arrParam1.getArray());
              System.out.println(this.getClass() + " -- " + arrParam1.length());
              System.out.println("arrParam2 - " + arrParam2);
              System.out.println("arrParam2 - " + arrParam2);
              System.out.println(this.getClass() + " ARRAY - " + arrParam2.getArray());
              System.out.println(this.getClass() + " -- " + arrParam2.length());
              Object[] params =
                   { dchannelId,
                        arrParam1,
                        specialCode,
                        dchannelId,
                        arrParam2,
                        specialCode
              setWhereClauseParams(params);
              System.out.println("DONE WITH " + this.getClass() + ".setParams()");
        catch(Exception ex)
              ex.printStackTrace(System.out);
      }the toSQLNumberList() method is defined in our App module baseclass as follows:
      public ARRAY toSQLNumberList(Collection coll)
           debug("toSQLNumberList()");
           DBTransaction txn = (DBTransaction)getTransaction();
           debug("txn - " + txn + " : " + txn.getClass());
           return NWSUtil.toSQLNumberList(coll, getConnection(txn));
      public static ARRAY toSQLNumberList(Collection c, Connection connection)
        //printTrace();
        debug("toSQLNumberList()");
        try
          ArrayDescriptor numberList = ArrayDescriptor.createDescriptor("NUMBERLIST", connection);
          NUMBER[] elements = new NUMBER[c == null ? 0 : c.size()];
          if (elements.length > 0 )
            Iterator iter = c.iterator();
            for (int i = 0; iter.hasNext(); i++)
              elements[i] = new NUMBER(iter.next().toString());
          return new ARRAY(numberList, connection, elements);
        catch (Exception ex)
          ex.printStackTrace();
          return null;
      protected Connection getConnection(DBTransaction dbTransaction)
        //return null;
        debug("Inside getConnection()");
        CallableStatement s = null;
        try
           * Getting Conenction in BC4J is dirty but its better
           * as otherwise we might end up coding with connections
           * and the Transaction Integrety will be
          s = dbTransaction.createCallableStatement("BEGIN NULL; END;", 0);
          debug("DOING s.getConnection()...");
          Connection conn = s.getConnection();
          debug("DONE WITH  s.getConnection()...");
          /*try
                throw new Exception("TEST");
           catch (Exception ex)
                ex.printStackTrace(System.out);
          debug("conn CLASS - " + conn.getClass());
          return conn;
        catch (Exception ex)
          ex.printStackTrace();
          return null;
        finally
          try { s.close(); }
          catch (Exception ex) {}
      }Whenever we try setting the parameters in view using setParams() and use this view to set the model of a java control it thorws the following exception :
    [2006-10-10 12:34:48,797 AWT-EventQueue-0 ERROR] JBO-28302: Piggyback write error
    oracle.jbo.PiggybackException: JBO-28302: Piggyback write error
         at oracle.jbo.common.PiggybackOutput.getPiggybackStream(PiggybackOutput.java:185)
         at oracle.jbo.common.JboServiceMessage.marshalRefs(JboServiceMessage.java:267)
         at oracle.jbo.server.remote.PiggybackManager.marshalServiceMessage(PiggybackManager.java:343)
         at oracle.jbo.server.remote.PiggybackManager.marshalServiceMessage(PiggybackManager.java:316)
         at oracle.jbo.server.remote.AbstractRemoteApplicationModuleImpl.processMessage(AbstractRemoteApplicationModuleImpl.java:2283)
         at oracle.jbo.server.ApplicationModuleImpl.doMessage(ApplicationModuleImpl.java:7509)
         at oracle.jbo.server.remote.AbstractRemoteApplicationModuleImpl.sync(AbstractRemoteApplicationModuleImpl.java:2221)
         at oracle.jbo.server.remote.ejb.ServerApplicationModuleImpl.doMessage(ServerApplicationModuleImpl.java:79)
         at oracle.jbo.server.ejb.SessionBeanImpl.doMessage(SessionBeanImpl.java:474)
         at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
         at com.evermind.server.ejb.interceptor.system.TxBeanManagedInterceptor.invoke(TxBeanManagedInterceptor.java:53)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
         at com.evermind.server.ejb.StatefulSessionEJBObject.OC4J_invokeMethod(StatefulSessionEJBObject.java:840)
         at RemoteAMReservation_StatefulSessionBeanWrapper906.doMessage(RemoteAMReservation_StatefulSessionBeanWrapper906.java:286)
         at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.evermind.server.rmi.RmiMethodCall.run(RmiMethodCall.java:53)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    ## Detail 0 ##
    java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
         at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
         at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1245)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1069)
         at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1245)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1069)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
         at oracle.jbo.common.SvcMsgResponseValues.writeObject(SvcMsgResponseValues.java:116)
         at sun.reflect.GeneratedMethodAccessor65.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:890)
         at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1333)
         at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
         at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
         at oracle.jbo.common.PiggybackOutput.getPiggybackStream(PiggybackOutput.java:173)
         at oracle.jbo.common.JboServiceMessage.marshalRefs(JboServiceMessage.java:267)
         at oracle.jbo.server.remote.PiggybackManager.marshalServiceMessage(PiggybackManager.java:343)
         at oracle.jbo.server.remote.PiggybackManager.marshalServiceMessage(PiggybackManager.java:316)
         at oracle.jbo.server.remote.AbstractRemoteApplicationModuleImpl.processMessage(AbstractRemoteApplicationModuleImpl.java:2283)
         at oracle.jbo.server.ApplicationModuleImpl.doMessage(ApplicationModuleImpl.java:7509)
         at oracle.jbo.server.remote.AbstractRemoteApplicationModuleImpl.sync(AbstractRemoteApplicationModuleImpl.java:2221)
         at oracle.jbo.server.remote.ejb.ServerApplicationModuleImpl.doMessage(ServerApplicationModuleImpl.java:79)
         at oracle.jbo.server.ejb.SessionBeanImpl.doMessage(SessionBeanImpl.java:474)
         at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
         at com.evermind.server.ejb.interceptor.system.TxBeanManagedInterceptor.invoke(TxBeanManagedInterceptor.java:53)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:69)
         at com.evermind.server.ejb.StatefulSessionEJBObject.OC4J_invokeMethod(StatefulSessionEJBObject.java:840)
         at RemoteAMReservation_StatefulSessionBeanWrapper906.doMessage(RemoteAMReservation_StatefulSessionBeanWrapper906.java:286)
         at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.evermind.server.rmi.RmiMethodCall.run(RmiMethodCall.java:53)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)This is a typical interaction between 2 server-side components (view-object and app module). Now the question is why is this exception thrown? Any answers?
    This application is one that we have migrated from 904 to 1013 and are trying to get it running in 3-tier.
    Regards,
    Anupam

    Sorry I missed out some semicolons, the script follws:
    -- The following TABLE was created to simulate the issue
    CREATE TABLE TEST_OBJECT
         ASSET_ID NUMBER,
         OBJECT_ID NUMBER,
         NAME VARCHAR2(50)
    INSERT INTO TEST_OBJECT VALUES(1,1,'AAA');
    INSERT INTO TEST_OBJECT VALUES(2,2,'BBB');
    INSERT INTO TEST_OBJECT VALUES(3,3,'CCC');
    COMMIT;
    SELECT * FROM TEST_OBJECT;
    -- The following TYPES was created to simulate the issue
    CREATE OR REPLACE
    TYPE DUTYRESULTOBJECTTAB AS TABLE OF DUTYRESULTOBJECT;
    CREATE OR REPLACE
    type DutyResultObject as object
    ( ASSET_ID number,
      OBJECT_ID number,
      NAME varchar2(150)
    -- The following PACKAGE N FUNCTION was created to simulate the issue
    CREATE OR REPLACE PACKAGE TESTOBJECTPKG
    IS
         FUNCTION OBJECTSEARCH(P_RESOURCE IN NUMBERLIST) RETURN DUTYRESULTOBJECTTAB;
    END;
    CREATE OR REPLACE PACKAGE BODY TESTOBJECTPKG
    IS
         FUNCTION OBJECTSEARCH(P_RESOURCE IN NUMBERLIST) RETURN DUTYRESULTOBJECTTAB
         IS
           BULKDUTYRESULTOBJECTTAB DUTYRESULTOBJECTTAB;
         BEGIN
           SELECT DUTYRESULTOBJECT(ASSET_ID, OBJECT_ID, NAME)
           BULK COLLECT INTO BULKDUTYRESULTOBJECTTAB
           FROM TEST_OBJECT;
           RETURN BULKDUTYRESULTOBJECTTAB;
         END;
    END;
    [\code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • CallableStatament for selection stored procedure

    hello,
    i write a jsp page where there are inputs. when i click on a button i want to search elements in my sql server database. to do that, i call a stored procedure :
    CREATE PROCEDURE PS_ELTS
    @param0 VARCHAR(40),
    @param1 VARCHAR(10),
    @param2 VARCHAR(6),
    @param3 VARCHAR(6),
    @param4 VARCHAR(40)
    AS
    SELECT ELTS.NAME,
    ELTS.TEL,
    ELTS.ADR1,
    ELTS.ADR2,
    ELTS.SERV
    FROM ELTS
    WHERE (ELTS.NAME LIKE @param0 OR @param0 IS NULL)
    AND (ELTS.TEL LIKE @param1 OR @param1 IS NULL)
    AND (ELTS.ADR1 LIKE @param2 OR @param2 IS NULL)
    AND (ELTS.ADR2 LIKE @param3 OR @param3 IS NULL)
    AND (ELTS.SERV LIKE @param4 OR @param4 IS NULL)
    ORDER BY ELTS.NAME, ELTS.TEL
    i have a java class elts as business object. in the class, there is a method search which takes an elts event, connects to the database and gets elements which are ok. if all parameters are null, i get every lines of ELTS table. it's ok. if one or more of the parametre is not null, i don't get any line. this is the method :
    public void search(UtilBean bean) throws Exception {
    int i = 0;
    Class.forName(driver);
    Connection connection = DriverManager.getConnection(url, login, password);
    if (connection != null) {
    connectionOk = true;
    this.setNAME(beanrecherche.getNAME());
    this.setTEL(beanrecherche.getTEL());
    this.setADR1(beanrecherche.getADR1());
    this.setADR2(beanrecherche.getADR2());
    this.setSERV(beanrecherche.getSERV());
    String aProc = "{call PS_ELTS(?,?,?,?,?)}";
    CallableStatement aStatement = connection.prepareCall(aProc);
    aStatement.setString(1, fmt_sqlChaineLike(this.getNAME()));
    aStatement.setString(2, fmt_sqlChaineLike(this.getTEL()));
    aStatement.setString(3, fmt_sqlChaineLike(this.getADR1()));
    aStatement.setString(4, fmt_sqlChaineLike(this.getADR2()));
    aStatement.setString(5, fmt_sqlChaineLike(this.getSERV()));
    aStatement.execute();
    ResultSet rs = aStatement.getResultSet();
    while (rs.next()) {
         i++;
    UtilBean util = new UtilBean();
    util.setNAME(rs.getString("NAME"));
    util.setTEL(rs.getString("TEL"));
    util.setADR1(rs.getString("ADR1"));
    util.setADR2(rs.getString("ADR2"));
    util.setSERV(rs.getString("SERV"));
    listUtil.add(util);
    do i do something wrong ? is there a solution to this problem ?

    i found what's wrong. in my stored procedure, i defined parameters like this :
    @param0 VARCHAR(40),
    @param1 VARCHAR(10),
    @param2 VARCHAR(6),
    @param3 VARCHAR(6),
    @param4 VARCHAR(40)
    when i use :
    aStatement.setString(1, this.getNAME());
    java sends a 40 characters long string to the stored procedure so if i write 'hello', the stored procedure gets 'hello '. any element is like that in the database so i must change the stored procedure :
    (ELTS.NAME LIKE @param0 OR @param0 IS NULL) became (ELTS.NAME LIKE rtrim(ltrim(@param0)) OR @param0 IS NULL)

  • Convert String to CLOB problem, CLOB is a input parameter in the procedure.

    I can not flush and close "Writer"??
    The following code:
    CLOB inclob=null;
    CallableStatement csr=conn.prepareCall ("begin TestClob(?); end;");
    csr.registerOutParameter (1, Types.CLOB);
    inclob = CLOB.createTemporary(conn,false,CLOB.DURATION_CALL);
    inclob .open(CLOB.MODE_READWRITE);
    Writer tempClobWriter = inclob.getCharacterOutputStream();
    tempClobWriter.write("This is In CLOB");
    // Flush and close the stream
    tempClobWriter.flush(); // problem is here
    tempClobWriter.close();//problem is here
    inclob.close();// this works
    Btw:
    How to use CLOB.setString() to specify string to CLOB directly?
    Message was edited by:
    user515324

    sorry, I fogot mention the error is "No data to read from socket"
    My Oracle JDBC driver is 9.2.0.4, Oracle database is 10.2.1.0
    Some guy said it is driver's problem.

  • $200 reward to solve problem with JDBC and CLOB.getCharacterOutputStream

    I'm trying to update CLOB with the getCharacterOutputStream as suggested in the example code. It works with US7ASCII DB instance but not instances in UTF8.
    I've been browsing through all the Oracle doc's and found some rather confusing statements:
    In the page at http://oradoc.photo.net/ora816/java.816/a81354/oralob2.htm#1043220
    it says: [When writing to or reading from a CLOB, the JDBC drivers perform all character set conversions for you.]
    also: [The oracle.sql.CLOB class supports all the character sets that the Oracle data server supports for CLOB types.]
    So far so good.
    In the page at http://oradoc.photo.net/ora816/java.816/a81354/oraint3.htm#1012518
    it says [The oracle.sql package supports these datatypes in several ways: CLOBs point to large fixed-width character data items (that is, characters that require a fixed number of bytes per character) and are supported by the oracle.sql.CLOB class.]
    Ooh no! Is this for real? UTF8 is variable width and does this mean it is not supported?
    Any way to get around this?
    In the page at http://oradoc.photo.net/ora816/java.816/a81358/03_pub2.htm#36009
    says [6.The mappings to oracle.sql classes are optimal because they preserve data formats and require no character-set conversions (apart from the usual network conversions). Those classes are especially useful in applications that "shovel" data between SQL and Java.]
    "No character set conversion"? Very confusing!
    I've been hammering on this CLOB/JDBC/UTF8 problem for more than a week now and I really appreciate some solutions, workarounds, or whatever help I can get. I'm running java stored procedure in 8.1.6 on Linux RH6.2.
    For your trouble, I'd pay $200 for the first guy who come up with a verifiable solution.

    This is just findings based upon your comments:
    Please refer to document Oracle8i National Language Support Guide
    Release 2 (8.1.6) from Oracle Documentation Library, Release 8.1.7
    Chapter 6 Java,
    There its clearly mention that:
    "Oracle JDBC drivers provide globalization support by allowing users to retrieve data from or insert data into a database in any character set that Oracle supports. Because Java strings are UCS2 encoded (16-bit Unicode) for JDBC programs, the target character set on the client is always UCS2. Character set conversion is required to convert data from the database character set (Db Charset) to UCS2. This applies to CHAR, LONG, CLOB, and VARCHAR2 data types; RAW data is not converted. "
    Also..please refer this...
    "oracle.sql.CLOB's method getCharacterStream() returns the contents of a CLOB as a Unicode stream."
    "The techniques that Oracle's drivers use to perform character set conversion for Java applications depend on the character set the database uses. The simplest case is where the database uses a US7ASCII or WE8ISO8859P1 character set. In this case, the driver converts the data directly from the database character set to UCS2,which is used in Java applications. "
    "If you are working with databases that employ a non-US7ASCII or non-WE8ISO8859P1 character set (for example, Japanese or Korean), then the driver converts the data, first to UTF8, then to UCS2. "
    In my case the characte-set of the database is WE8ISO8859P1 and for security reason i can't change the character set but my feeling is that if you are updating the CLob from the java client you are forming a reference of a clob in the client which is UCS2 at the Java side. Now when you are populating the clob through java.io.Writer and call the procedure to pass the reference of the clob to the procedure then I believe the JDBC will convert the UCS2 datatype of Clob to UTF8 in the database.
    You can try out the code snippet:
    package ServletGDC;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import oracle.sql.*;
    import java.sql.*;
    import oracle.jdbc.driver.*;
    import ClassesGDC.*;
    public class testUpload extends HttpServlet {
    private String m_strMessage="";//It stores the message to be uploaded along with the Document
    Connection conn=null;
    public void doPost(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    String strContent="";
    //res.setContentType("application/msword");
    res.setContentType("text/html");
    PrintWriter out = res.getWriter();
    try {
    CallableStatement cmt=null;
    OutputStream output=null;
    ByteArrayOutputStream byteoutput=null;
    String strDocString="";
    oracle.sql.CLOB tempClob = null;
    String strPassedFileName="";     // the file name passed in the request object
    String strStdFilename="";//the file name to be given to the best practice
    String strSaveDirectory="";     //the directory in which the bp is to be saved
    String strParamName="";//name of parameters
    String strParamValue="";//value of parameters
    int intTempVariable=0; // temporaty variable
    long lngSizeOfFileUploaded=0;//stores the size of the file which had been uploaded in the file system
    File filePathOfFileUploaded=null;//stores the path of the file uploaded to the file system
    String strQuery="";
    //ST------------checks if the user has logged in or not-----------------------
    HttpSession session=req.getSession(true);
    if(req.getContentLength()>20*1024*1024)
    throw new skip("The size of the posted content is more than 10 MB . If you have a best practice whose size is more than 1 MB please mail it to Us.");
    byteoutput = new ByteArrayOutputStream();
    MultipartParser mp = new MultipartParser(req, 20*1024*1024); // 10MB is the limit of the file to be uploaded
    Part part;//Its an abstact part which helps in retrieving information about the file and the parameters
    while ((part = mp.readNextPart()) != null) {//Reads the next part
    strParamName = part.getName();
    // the following if is executed if the part is for a parameter rather than a file
    if (part.isParam()) {
    }else if (part.isFile()) {
    // it's a file part
    m_strMessage="inside file part";
    FilePart filePart = (FilePart) part;
    strPassedFileName = filePart.getFileName();
    strContent= filePart.getContentType();
    out.println("<BR><font color=red>strPassedFileName is "+strPassedFileName+"</font>");
    if(strPassedFileName != null || !(strPassedFileName.trim().equals("")) ) {
    // the part actually contained a file
    out.println("<BR><font color=red> before forming long</font>");
    //lngSizeOfFileUploaded = filePart.writeTo(filePathOfFileUploaded);      //the statement upload the bestpractice in the
    lngSizeOfFileUploaded = filePart.writeTo(byteoutput);     //specified file path filePathOfFileUploaded.
    out.println("<BR><font color=red> after file is written into the outputstream</font>");
    else {
    throw new skip("The file name is null or it is empty space. Files in such Format are not accepted");
    }//end of else if
    }//end of while loop
    if(     lngSizeOfFileUploaded==0)     {// the size of the file uploaded is zero then the file supplied was not proper and hence exception is to be thrown
    //if(filePathOfFileUploaded.exists())
    //     filePathOfFileUploaded.delete();
    throw new skip("The File could not be uploaded,Possible reasons may be that the file is sent null or the file is corrupted");
    //END---------------the file is uploaded in the proper directory--------------------
    //res.setContentType(strContent);
    out.println("<BR><font color=red>long value is : "+lngSizeOfFileUploaded+" and content is "+strContent+"</font>");
    String strbyte= byteoutput.toString();
    byteoutput.flush();
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // Establish network connection to database
    conn = DriverManager.getConnection("jdbc:oracle:thin:@pc-p32670:1521:GDCDBI","gdc_user","myuser");
    //if(conn!=null)
    out.println("<BR><font color=red>Connection formed"+conn);
    //els
    //out.println("<BR><font color=red>long value is : "+strbyte+"</font>");
    try{
    tempClob = oracle.sql.CLOB.createTemporary(conn,true, oracle.sql.CLOB.DURATION_SESSION);
    out.println("<BR><font color=red>tempClob : "+tempClob);
    tempClob.open( oracle.sql.CLOB.MODE_READWRITE);
    java.io.Writer tempClobWriter = tempClob.getCharacterOutputStream();
    // writing the string formed from the multipart file to the clob
    tempClobWriter.write(strbyte);
    if(tempClob!=null){}
    out.println("<BR><font color=red>CLOB value is : "+tempClob+"</font>");
    strQuery="{call INSERT_CLOB(?,?)}";
    cmt=conn.prepareCall(strQuery);
    cmt.setString(1,strPassedFileName);
    cmt.setClob(2,tempClob);
    cmt.registerOutParameter(2,java.sql.Types.CLOB);
    cmt.execute();
    tempClobWriter.flush();
    tempClobWriter.close();
    tempClob.freeTemporary();
    //res.setContentType(strContent);
    //strDocString.toString();
    out.println("<BR><font color=red>bob is "+strbyte+"</font>");
    tempClob.close();
    }catch(Exception e){
    tempClob.close();
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    //e.printStackTrace(out);
    cmt.close();
    //out.println("<BR><font color=red><h2><b>SUCCESS</h2></font>");
    //res.sendRedirect("../test/showfile.jsp?contentype="+strContent.trim()+"");
    }catch(Exception e){
    java.util.Date d = new java.util.Date();
    String s =d.toString();
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    //e.printStackTrace(out);
    }finally{
    try{
    if(conn!=null)
    conn.close();
    }catch(Exception e){
    out.println("<font color=blue> Error is :"+e.getMessage()+"</font>");
    }// end of finally
    } //end of doPost
    } //end of class
    in the Procedure you will be inserting/updating the clob in a table with the reference clob in the out parameter of the procedure
    Thanks.

  • Problem with  JFrame (I'm thinking) from enother java program

    Hi,
    I'm using jasperReport and running viewReport from my java application.
    JasperPrint jasperPrint = JasperFillManager.fillReport(
                             jasperReport, parameters, conn);
                   JasperViewer.viewReport(jasperPrint, true);
    My problem is when I'm closing the view report, my java aplication closing twe!
    I think it's because the view frame sel exit(0)?
    and one more question, if I run this viewReport from JButton in a JDIalog, the view location is under my dialog, how can I set this view to be allways on top??
    Thanks alot :)

    The following code is running without problems (SQLSERVER),and you can compared with yours.
    public static Connection con;
         public  Statement sta;
         public ResultSet rst;
         public CallableStatement  cas = null;
         public int OutPut;
    public void doProcedures(String str,Vector vec){
                   try {
         String s=null;
                        con=null;
                        rst=null;
                        Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
                                            con = DriverManager.getConnection(getConnectionString(), "sa","");               
                                         s=str;
                        s="{call"+" "+s+"(?,?,?)}";
                    cas=con.prepareCall(s);
                       cas.registerOutParameter(1, java.sql.Types.INTEGER ); 
                       for(int i =0;i<vec.size();i++){                   
                      cas.setInt(i+2,Integer.parseInt ((String)vec.elementAt(i)));  
                       cas.execute() ;
                       OutPut =cas.getInt(1);
                       rst = cas.executeQuery();
                      // while(rst.next()){
                           // String output=rst.getString(1);
                       //rst.close() ;
                   } catch (Exception e) {
                        e.printStackTrace();
    Good Luck,baby!!!

  • Problem  with BC4J in 10g: incorrect Date formatting

    I have PL/SQL procedure, which is called from bc4j-struts-application like this:
    CallableStatement cs = getDBTransaction().createCallableStatement(FIND_USER_RESP_STMT,0);
    cs.execute();
    It return an exeption with this message:
    ORA-01403: no data found
    ORA-06512: at "CRN.CRN_UTIL", line 115
    ORA-06512: at "CRN.CRN_UTIL", line 323
    ORA-06512: at "CRN.CRN_RESPONSIBILITY", line 85
    ORA-01843: not a valid month
    ORA-06512: at line 1
    I don't send any data parameter for this procedure. When I try to call it from JDeveloper connections debug, it runs succesfully. I try to create bc4j entity to query:
    select to_char(sysdate, 'DD-MON-YYYY') X,
    to_char(sysdate, 'DD-MM-YYYY') Y from dual
    and it retrieves:
    27-¿¿¿-2004
    27-09-2004
    Date constant is used in PL/SQL procedure with format 'DD-MON_YYYY', but I can't change it, because it used by many other applications.
    My local setting is english, USA, and I have the second language on my PC - russian.
    JDeveloper 9.0.5.2. This code runs succesfully in JDeveloper 9.0.3.3.
    How can I send bc4j date setting in normal format to solve this problem? And where can I find bc4j local settings, which are sended by bc4j to server?
    Regards, Nikolay

    Hello,
    The problem is still available. Could anybody help?
    Regard

  • Problem with store ResultSet and show result in table

    Hi, I'm kind of new in ADF, I need to store ResultSet and show result in table-component. I have two problems:
    1) I get my ResultSet by calling callStoredProcedure(...) and this returns actually ref_cursor as ResultSet.
    When I try to println() contains of this result set in this method - it works OK (commented part),
    but when I want to println() somewhere else (eg. in retrieveRefCursor() method) it doesn't work.
    The problem is that the scrollability of the ResultSet is lost - it becomes a TYPE_FORWARD_ONLY ResultSet.
    Is there any way to store data from ref_cursor for a long time?
    2) My second problem is "store any result set and show this data in table". I have tried use method storeNewResultSet() but
    without result (table contains only "No rows yet" and everything seems to be OK - no exception, no warning, no error...).
    I have tried to call this method with ResultSet from select on dbs (without resultSet as ref_cursor ) - no result with createRowFromResultSet(),
    storeNewResultSet(), setUserDataForCollection()...
    I've tried a lot of ways to do this, but it doesn't work. I really don't know how to make it so it can work.
    Thanks for your help.
    ADF BC, JDev 11.1.1.0
    This is my code from ViewObjectImpl
    package tp.model ;
    import com.sun.jmx.mbeanserver.MetaData ;
    import java.sql.CallableStatement ;
    import java.sql.Connection ;
    import java.sql.PreparedStatement ;
    import java.sql.ResultSet ;
    import java.sql.ResultSetMetaData ;
    import java.sql.SQLException ;
    import java.sql.Statement ;
    import java.sql.Types ;
    import oracle.jbo.JboException ;
    import oracle.jbo.server.SQLBuilder ;
    import oracle.jbo.server.ViewObjectImpl ;
    import oracle.jbo.server.ViewRowImpl ;
    import oracle.jbo.server.ViewRowSetImpl ;
    import oracle.jdbc.OracleCallableStatement ;
    import oracle.jdbc.OracleConnection ;
    import oracle.jdbc.OracleTypes ;
    public class Profiles1ViewImpl extends ViewObjectImpl {
        private static final String SQL_STM = "begin Pkg_profile.get_profile_list(?,?,?,?);end;" ;
        public Profiles1ViewImpl () {
        /* 0. */
        protected void create () {
            getViewDef ().setQuery ( null ) ;
            getViewDef ().setSelectClause ( null ) ;
            setQuery ( null ) ;
        public Connection getCurrentConnection () throws SQLException {
            // Note that we never execute this statement, so no commit really happens
            Connection conn = null ;
            PreparedStatement st = getDBTransaction ().createPreparedStatement ( "commit" , 1 ) ;
            conn = st.getConnection () ;
            st.close () ;
            return conn ;
        /* 1. */
        protected void executeQueryForCollection ( Object qc , Object[] params , int numUserParams ) {
            storeNewResultSet ( qc , retrieveRefCursor ( qc , params ) ) ;
            // callStoredProcedure ( qc , SQL_STM ) ;
            super.executeQueryForCollection ( qc , params , numUserParams ) ;
        /* 2. */
        private ResultSet retrieveRefCursor ( Object qc , Object[] params ) {
            ResultSet rs = null ;
            rs = callStoredProcedure ( qc , SQL_STM ) ;
            return rs ;
        /* 3. */
        public ResultSet callStoredProcedure ( Object qc , String stmt ) {
            CallableStatement st = null ;
            ResultSet refCurResultSet = null ;
            try {
                st = getDBTransaction ().createCallableStatement ( stmt , 0 ) ; // call 
                st.setObject ( 1 , 571 ) ; //set id of my record to 571
                st.registerOutParameter ( 2 , OracleTypes.CURSOR ) ; // my ref_cursor
                st.registerOutParameter ( 3 , Types.NUMERIC ) ;
                st.registerOutParameter ( 4 , Types.VARCHAR ) ;
                st.execute () ; //executeUpdate
                System.out.println ( "Numeric " + st.getObject ( 3 ) ) ;
                System.out.println ( "Varchar " + st.getObject ( 4 ) ) ;
                refCurResultSet = ( ResultSet ) st.getObject ( 2 ) ; //set Cursoru to ResultSet
                //   setUserDataForCollection(qc, refCurResultSet); //don't work
                //   createRowFromResultSet ( qc , refCurResultSet ) ; //don't work
                /* this works but only one-time call - so my resultSet(cursor) really have a data
                while ( refCurResultSet.next () ) {
                    String nameProfile = refCurResultSet.getString ( 2 ) ;
                    System.out.println ( "Name profile: " + nameProfile ) ;
                return refCurResultSet ;
            } catch ( SQLException e ) {
                System.out.println ( "sql ex " + e ) ;
                throw new JboException ( e ) ;
            } finally {
                if ( st != null ) {
                    try {
                        st.close () ; // 7. Close the statement
                    } catch ( SQLException e ) {
                        System.out.println ( "sql exx2 " + e ) ;
        /* 4. Store a new result set in the query-collection-private user-data context */
        private void storeNewResultSet ( Object qc , ResultSet rs ) {
            ResultSet existingRs = getResultSet ( qc ) ;
            // If this query collection is getting reused, close out any previous rowset
            if ( existingRs != null ) {
                try {
                   existingRs.close () ;
                } catch ( SQLException s ) {
                    System.out.println ( "sql err " + s ) ;
            setUserDataForCollection ( qc , rs ) ; //should store my result set
            hasNextForCollection ( qc ) ; // Prime the pump with the first row.
        /*  5. Retrieve the result set wrapper from the query-collection user-data      */
        private ResultSet getResultSet ( Object qc ) {
            return ( ResultSet ) getUserDataForCollection ( qc ) ;
        // createRowFromResultSet - overridden for custom java data source support - also doesn't work
       protected ViewRowImpl createRowFromResultSet ( Object qc , ResultSet resultSet ) {
            ViewRowImpl value = super.createRowFromResultSet ( qc , resultSet ) ;
            return value ;
    }

    Hi I have the same problem like you ...
    My SQL Definition:
    CREATE OR REPLACE TYPE RMSPRD.NB_TAB_STOREDATA is table of NB_STOREDATA_REC
    CREATE OR REPLACE TYPE RMSPRD.NB_STOREDATA_REC AS OBJECT (
       v_title            VARCHAR2(100),
       v_store            VARCHAR2(50),
       v_sales            NUMBER(20,4),
       v_cost             NUMBER(20,4),
       v_units            NUMBER(12,4),
       v_margin           NUMBER(6,2),
       v_ly_sales         NUMBER(20,4),
       v_ly_cost          NUMBER(20,4),
       v_ly_units         NUMBER(12,4),
       v_ly_margin        NUMBER(6,2),
       v_sales_variance   NUMBER(6,2)
    CREATE OR REPLACE PACKAGE RMSPRD.NB_SALES_DATA
    AS
    v_sales_format_tab   nb_tab_storedata;
    FUNCTION sales_data_by_format_gen (
          key_value         IN       VARCHAR2,
          l_to_date         IN       DATE DEFAULT SYSDATE-1,
          l_from_date       IN       DATE DEFAULT TRUNC (SYSDATE, 'YYYY')
          RETURN nb_tab_storedata;
    I have a PLSQL function .. that will return table ..
    when i use this in sql developer it is working fine....
    select * from table (NB_SALES_DATA.sales_data_by_format_gen('TSC',
                                        '05-Aug-2012',
                                        '01-Aug-2012') )
    it returning table format record.
    I am not able to call from VO object. ...
    Hope you can help me .. please tell me step by step process...
    protected Object callStoredFunction(int sqlReturnType, String stmt,
    Object[] bindVars) {
    System.out.println("--> 1");
    CallableStatement st = null;
    try {
    st = getDBTransaction().createCallableStatement("begin ? := " +"NB_SALES_DATA.sales_data_by_format_gen('TSC','05-Aug-2012','01-Aug-2012') ; end;", 0);
    System.out.println("--> 2");
    st.executeUpdate();
    System.out.println("--> 3");
    return st.getObject(1);
    catch (SQLException e) {
    e.printStackTrace();
    throw new JboException(e);

Maybe you are looking for

  • [GeForceFX] My monitor is blank

    When i played some games ( Need For Speed Underground 2 or Swat4 ) with a some time, my video cards apears had some problem, because my monitor goes to blank, and the monitor light is turn off and on, i don t know how to solve!I try to install other

  • HT3939 i am trying to find the make/manufacture number on my phone and model number.

    i am trying to find my device manufacture/make on the back of the box and model number, can someone please help

  • How to distribute Oracle Argus Cloud Service?

    Hi, In order to apply to distribute Oracle Argus Cloud Service Knowledge Zone products, you must meet the following criteria: Be a Gold, Platinum, or Diamond member of the Oracle PartnerNetwork in good standing with a valid OPN Agreement. Have a vali

  • Multiple tenant on Exadata disk configuration

    Hi, Exadata has pre-built 2 Node RAC, ASM 3 Disk Group configured. Please can I know what is the disk group configuration for Multi tenant consolidation on exadata. Thanks

  • How to sync ITunes tv shows to IPad2?

    How do I sync my ITunes puchased TV shows on to my IPad 2?  I just got my IPad 2 a few days ago and I am stumped by this problem. Thank you for any help you can give me. Cathy