Casting prob

Imagine, I have an abstract class with 6 subclasses extending it.
Objects of these subclasses are being put in an ArrayList.
Now, when I loop the ArrayList and want to retrieve the attributes of each object I have to cast each object in the ArrayList to it's specific subclass, so in the end i get 7 declarations for this loop.
Example:
ArrayList list = getArrayList();
HeadClass hc;
SubClass1 sc1;
SubClass2 sc2;
SubClass3 sc3;
SubClass4 sc4;
SubClass5 sc5;
SubClass6 sc6;
for (int j = 0; j < list.size; j++) {
hc = (HeadClass) list .get(j);
if (hc instanceof SubClass1) {
sc1 = (SubClass1) hc;
sc1.get(...);
sc1.get(...);
} else if (hc instanceof SubClass2) {
Isn't there a way to get rid of all these castings ?: HeadClass hc;
SubClass1 sc1;
.....

I can put abstract methods on the abstract class for the subclasses to implement.
But that means that some implemented methods don't really belong to that subclass.
I cab throw then an exception in those methods that are not needed in that subclas if someone calls it.
Would this be good ? Is there really no other solution then to use abstract methods ?

Similar Messages

  • Re-casting of object from control reference

    I feel like this question is likely answered elsewhere, but after days of searching I couldn't find an answer. Sorry if I'm missing the answer in some obvious place.
    I'm given a reference to a cluster control and told that the elements of the cluster are all children of parent class A. Using the controls[] property I get an array of the elements, and the value property of each of those elements gives a variant that can be turned into class A. At that point, all of the object oriented overriding and private data stuff works as expected.
    So far so good.
    But one method I call on those objects changes the private data, and I need to update the control with the updated object. There I get a runtime error because the control isn't A but some child class of A.
    I think this is where Preserve Runtime Class comes into play, but since I only get a reference to work with, what do I do? This is especially frustrating because debugging probes show that LabVIEW knows the child class on the wire, but I can't see how to tell LabVIEW to cast down to the class that it knows it has.
    For example, is there some way to use the ClassName property of the control to cast the object of class A into the child that the control is expecting?
    Solved!
    Go to Solution.

    nathand wrote:
    So your trying to write to the specific control within the cluster, by reference, as a variant, and you're getting an error? What's the actual text of the error?
    Really you shouldn't ever be using a front panel object this way, especially one where the user never sees the data in it. For passing data around you should use a wire. Neither a wire nor a DVR will get you the ability to pass an arbitrary cluster, though, which it sounds like is what you're trying to do. With a bit more information we might be able to suggest a better approach.
    I don't have the text of the error handy, but it comes from the write value property node and basically says the given variant can't be converted to the type of the control. It happens only when the value is cast to the parent class, which makes sense.
    In other words, given a control of child type,
    control.value ---> variant ---> to parent ---> variant ---> control.value     failes with the error
    control.value ---> variant ---> to child ---> variant ---> control.value       succeeds
    So a solution would be a way to cast to the child instead of to the parent. LabVIEW knows what class the control contains; it is listed in a number of places from the ClassName property through the probe window. The problem is I know of no way to bridge the gap from "LabVIEW knows what class this thing is" to "have LabVIEW cast the variant to that class."
    I completely agree that I shouldn't have to ever be using a front panel control this way, but I don't want to get sidetracked into talking about the shortcomings of LabVIEW that have required such a use. Suffice it to say, that is the assignment.

  • The RAZR - Now with V CAST from Verizon Wireless

    Does anone know if this (The RAZR - Now with V CAST from Verizon Wireless) syncs with iSync? I don't see it here
    http://www.apple.com/macosx/features/isync/devices.html
    but I think the model is new.
    thanks
    roger

    There's a link on the howardforum board (see the hotlink in the above posting) to a site where you can download a new .plist (http://www.megaupload.com/?d=9PH5DVRU) I replaced the iSync .plist with the downloaded file and restarted my iMac.
    (the howardforum board has directions for "showing" the .plist in Applications; right click on the iSync application).
    iSync immediately recognized my phone via BLUETOOTH and I synched all my contacts wirelessly. I too bought the USB cable but never got it to work wired with iSync and don't need it now.
    The download also has a .TIFF of the RAZR, so your iSync panel will have an icon for it.
    Took a little trying (I am not used to this level of tinkering) but once I restarted the Mac, voila, no probs.
    PS - I am talking about the Verizon RAZR V3c. Good luck.
    iMac G5 20"   Mac OS X (10.4.3)  

  • Error in cast a variable

    these are few lines from my long STORED PROCEDURE actually i am new to oracle 11g please
    declare
    v_s nvarchar2(10);
    p_RN nvarchar2(10);
    begin
    v_s := v_s || cast(p_RN as nvarchar2(10)); - ERROR IS COMING IN THIS LINE
    end;
    error
    ORA-06550: line 5, column 39:
    PLS-00103: Encountered the symbol "(" when expecting one of the following:
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:
    please somebody help me

    Just a little explanation about the error message.
    ORA-06550: line 5, column 39:
    PLS-00103: Encountered the symbol "(" when expecting one of the following:
    Line 5 column 39 is the starting parenthesis of the "(10)". For using cast you can't add a lenght to the datatype.
    If you change that, then you get a different error message:
    declare
    v_s nvarchar2(10);
    p_RN varchar2(10);
    begin
      v_s := v_s || cast(p_RN as nvarchar2); -- ERROR IS COMING IN THIS LINE
    end;
    Fehler beim Start in Zeile 13 in Befehl:
    declare
    v_s nvarchar2(10);
    p_RN varchar2(10);
    begin
      v_s := v_s || cast(p_RN as nvarchar2); -- ERROR IS COMING IN THIS LINE
    end;
    Fehlerbericht:
    ORA-06550: line 5, column 22:
    PLS-00382: expression is of wrong type
    ORA-06550: line 5, column 3:
    PL/SQL: Statement ignored
    06550. 00000 -  "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:ORA-06550: line 5, column 22:
    PLS-00382: expression is of wrong type
    This shows that you can't convert/cast a nvarchzar type into another nvarchar type.
    It would work if you cast a number into a varchar2 type for example
    declare
    v_s nvarchar2(10);
    p_RN number(10);
    begin
      v_s := v_s || cast(p_RN as nvarchar2); -- ERROR IS COMING IN THIS LINE
    end;
    anonymer Block abgeschlossen.

  • My apps dance open and close on their own in my IPad 2 what can be the prob? I have already restored

    I got the charger flex or pin changed and now the apps dance on the screen, photos open and zoom in, then out, the other apps open and close. I have already restored the device with Itunes and prob is still there. What can be the problem? Any suggestion will be welcome. Thank you

    THANKS for your prompt reply  Bluetooth is off in my laptop and IPhone.. and in fact the reset is the only thing that can make it back to normal. But for a lil while. I wonder if it is the touch, or the home botton... both things are very expensive to replace, so I wouldn't like to spend $$ and continue having the prob.....

  • Error in cast multiset in collections

    DECLARE
    TYPE emp_dept_rec IS RECORD (
    v_sal emp.sal%TYPE,
    v_name emp.ename%TYPE,
    v_deptname dept.DEPTNAME%type
    TYPE emp_dept_tab_type IS TABLE OF emp_dept_rec;
    l_emp_dept_tab emp_dept_tab_type;
    type emp_tab is table of emp%rowtype;
    type l_emp_tab is table of emp%rowtype;
    type dept_tab is table of dept%rowtype;
    type l_dept_tab is table of dept%rowtype;
    cursor e1 is
    select * from emp;
    cursor d1 is select * from dept;
    begin
    OPEN e1;
    FETCH e1
    BULK COLLECT INTO l_emp_tab;
    open d1;
    FETCH d1
    BULK COLLECT INTO l_dept_tab;
    select cast(multiset (select em.sal,em,ename ,dep.DEPTNAME
    from table(l_emp_tab) em,table(l_dept_tab) dep
    where em.deptno=dep.deptno)
    as emp_dept_tab_type)
    into l_emp_dept_tab ;
    end;
    it is giving error as
    ORA-06550: line 43, column 25:
    PL/SQL: ORA-00923: FROM keyword not found where expected
    ORA-06550: line 39, column 5:
    PL/SQL: SQL Statement ignored

    Here is an example.
    SQL> CREATE OR REPLACE TYPE emp_rec IS OBJECT (
      2                      v_sal    NUMBER(7,2),
      3                      v_name   VARCHAR2(35),
      4                      v_empno  NUMBER(4),
      5                      v_deptno NUMBER(2)
      6                      )
      7  ;
      8  /
    Type created.
    SQL> CREATE OR REPLACE TYPE emp_tab IS TABLE OF emp_rec;
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE dept_rec IS OBJECT (
      2                      v_deptno NUMBER,
      3                      v_dname VARCHAR2(50)
      4                      )
      5  ;
      6  /
    Type created.
    SQL> CREATE OR REPLACE TYPE dept_tab IS TABLE OF dept_rec;
      2  /
    Type created.
    SQL> CREATE OR REPLACE TYPE emp_dept_rec IS
      2                     OBJECT (
      3                      v_sal     NUMBER,
      4                      v_name     VARCHAR2(35),
      5                      v_deptname VARCHAR2(30)
      6                      );
      7  /
    Type created.
    SQL> CREATE OR REPLACE TYPE emp_dept_tab_type IS TABLE OF emp_dept_rec;
      2  /
    Type created.
    SQL> set serverout on
    SQL> DECLARE
      2    l_emp_dept_tab emp_dept_tab_type; --emp_dept_tab_type declared in database
      3    l_emp_tab      emp_tab; --emp_tab declared in database
      4    l_dept_tab     dept_tab; --dept_tab declared in database
      5 
      6    CURSOR e1 IS
      7      SELECT emp_rec(sal, ename, empno, deptno) FROM emp; --Note the type casting here
      8 
      9    CURSOR d1 IS
    10      SELECT dept_rec(deptno, dname) FROM dept; --Note the type casting here
    11  BEGIN
    12    OPEN e1;
    13 
    14    FETCH e1 BULK COLLECT
    15      INTO l_emp_tab;
    16 
    17    OPEN d1;
    18 
    19    FETCH d1 BULK COLLECT
    20      INTO l_dept_tab;
    21 
    22    SELECT CAST(MULTISET (SELECT em.v_sal, em.v_name, dep.v_dname
    23                   FROM TABLE(l_emp_tab) em, TABLE(l_dept_tab) dep
    24                  WHERE em.v_deptno = dep.v_deptno) AS emp_dept_tab_type)
    25      INTO l_emp_dept_tab
    26      FROM DUAL;
    27    FOR i IN 1 .. l_emp_dept_tab.COUNT LOOP
    28      dbms_output.put_line(l_emp_dept_tab(i)
    29                           .v_sal || '--' || l_emp_dept_tab(i)
    30                           .v_name || '--' || l_emp_dept_tab(i).v_deptname);
    31    END LOOP;
    32 
    33  END;
    34  /
    1300--MILLER--ACCOUNTING
    5000--KING--ACCOUNTING
    2450--CLARK--ACCOUNTING
    3000--FORD--RESEARCH
    1100--ADAMS--RESEARCH
    3000--SCOTT--RESEARCH
    2975--JONES--RESEARCH
    800--SMITH--RESEARCH
    950--JAMES--SALES
    1500--TURNER--SALES
    2850--BLAKE--SALES
    1250--MARTIN--SALES
    1250--WARD--SALES
    1600--ALLEN--SALES
    PL/SQL procedure successfully completed.It is just for educational purpose, because the thing you have achieved by so much programming can be done easily by simple join in the table itself.
    user10447332 Newbie
    Handle: user10447332
    Status Level: Newbie
    Registered: Oct 20, 2008
    Total Posts: 227
    Total Questions: 153 (152 unresolved) >
    What a record! and most of the time you don't care to follow/revisit the thread also!.

  • Error in cast to MULTIPART

    Hi, I test the follow Jguru tutorial code for getting atacchements
    Multipart multipart = (Multipart)message.getContent();
    for (int i=0, n=multipart.getCount(); i<n; i++) {
    Part part = multipart.getBodyPart(i));
    String disposition = part.getDisposition();
    if ((disposition != null) &&
    ((disposition.equals(Part.ATTACHMENT) ||
    (disposition.equals(Part.INLINE))) {
    saveFile(part.getFileName(), part.getInputStream());
    But i have a problem of cast in this line
    Multipart mp = (Multipart)message.getContent();
    the error of CastClass is:
    java.lang.String cannot be cast to javax.mail.Multipart
    why????? Please help me
    Thanks

    Most likely you don't have a multipart message. See the msgshow.java
    demo program that comes with JavaMail.

  • Could not type cast in java embedding

    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    org.xml.sax.InputSource in = (org.xml.sax.InputSource) getVariableData("Invoke_1_getRoutingAndFrameJumpers_OutputVariable","getRoutingAndFrameJumpersResponse");
    Document doc = db.parse(in);
    In the above code I am trying to type cast the variable getRoutingAndFrameJumpersResponse into org.xml.sax.InputSource so that i can parse.
    I am not getting any error during compilation
    but I am unable to type cast some run time error is coming in the line were I am type casting but I am not able to see the runtime error.
    How can I see the runtime error in java embedding, how to type cast a variable into xml so that I can parse it.

    Hi Arun,
    Could you try using the bpelx:rename extension in an assign activity enables a BPEL process to rename an element through use of XSD type casting.
    <bpel:assign>
    <bpelx:rename elementTo="QName1"? typeCastTo="QName2"?>
    <bpelx:target variable="ncname" part="ncname"? query="xpath_str" />
    </bpelx:rename>
    </bpel:assign>
    Cheers
    A

  • Derive found flag in SQL with where clause using TABLE(CAST function

    Dear All,
    Stored procedure listEmployees
    ==========================
    CREATE OR REPLACE TYPE STRING_ARRAY AS VARRAY(8000) OF VARCHAR2(15);
    empIdList STRING_ARRAY
    countriesList STRING_ARRAY
    SELECT EMP_ID, EMP_COUNTRY, EMP_NAME, FOUND_FLAG_
    FROM EMPLOYEE WHERE
    EMP_ID IN
    (SELECT * FROM TABLE(CAST(empIdList AS STRING_ARRAY))
    AND EMP_COUNTRY IN
    (SELECT * FROM TABLE(CAST(countriesList AS STRING_ARRAY))
    =================
    I have a stored procedure which lists the employees using above simple query.
    Here I am using table CAST function to find the list of employees in one go
    instead of looping through each and every employee
    Everything fine until requirements forced me to get the FOUND_FLAG as well.
    Now I wanted derive the FOUND_FLAG by using rownum, rowid, decode functions
    but I was not successful
    Can you please suggest if there is any intelligent way to say weather the
    row is found for given parameters in the where clause?
    If not I may have to loop through each set of empIdList, countriesList
    and find the values individually just to set a flag. In this approach I can’t use
    the TABLE CAST function which is efficient I suppose.
    Note that query STRING_ARRAY is an VARRAY. It is very big in size and this procedure
    suppose to handle large sets of data.
    Thanks In advance
    Regards
    Charan
    Edited by: kmcharan on 03-Dec-2009 09:55
    Edited by: kmcharan on 03-Dec-2009 09:55

    If your query returns results, you have found them... so your "FOUND" flag might be a constant,...

  • Prob in decode function

    hi iam having prob with the following decode function
    declare
    c varchar2(20);
    begin
    select decode(deptno,
         10, 'accounting',
         20,'Research',
         30 ,'sales',
         40,'operations','UNKNOWN') into c from dept where loc='DALLAS';
    dbms_output.put_line('DEPARTMENT in DALLAS'||c);
    select decode(deptno,
         10, 'accounting',
         20,'Research',
         30 ,'sales',
         40,'operations','UNKNOWN') into c from dept where loc='INDIA';
    dbms_output.put_line('DEPARTMENT IN INDIA'||c);
    end;
    iam getting no_data_found exception which is reasonable..but what happened to 'unknown' clause in decode function.
    thank u
    rajiv

    DECODE only works on rows returned from the database. If there are no rows, DECODE has nothing to work on.
    Consider:
    SQL> SELECT DECODE(dummy, 'X', 'Found a row', 'No row')
      2  FROM dual;
    DECODE(DUMM
    Found a row
    SQL> SELECT DECODE(dummy, 'X', 'Found a row', 'No row')
      2  FROM dual
      3  WHERE 1=2;
    no rows selectedIf you want to have c contain UNKNOWN when there are no rows returned, you need to do something more like:
    DECLARE
    c VARCHAR2(20);
    BEGIN
       BEGIN
          SELECT DECODE(deptno, 10, 'accounting',
                                20,'Research',
                                30 ,'sales',
                                40,'operations','UNKNOWN')
          INTO c
          FROM dept
          WHERE loc='DALLAS';
       EXCEPTION
          c := 'UNKNOWN';
       END;
       DBMS_OUTPUT.Put_Line('DEPARTMENT in DALLAS'||c);
       BEGIN
          SELECT DECODE(deptno, 10, 'accounting',
                                20,'Research',
                                30 ,'sales',
                                40,'operations','UNKNOWN')
          INTO c
          FROM dept
          WHERE loc='INDIA';
       EXCEPTION
          c := 'UNKNOWN';
       END;
       DBMS_OUTPUT.Put_Line('DEPARTMENT IN INDIA'||c);
    END;HTH
    John

  • ISE 1.2 - Multiple NICs/Load Balancing for DHCP Probe

    Hello guys
    Just prepping an ISE 1.2 patch 8 setup in our organization. I am going for the virtual appliances with multiple NICs. It will be a distributed deployment with 4 x PSNs behind a load balancer and there is no requirement for wireless or guest user at the moment. I've got 2 points I will like to get some guidance on:
    Our DC has a dedicated mgmt network and I plan to IP the gig0 interface of the PANs, MNTs and PSNs from this subnet. All device admin, clustering, config replication, etc will be over this interface. However, RADIUS/probe/other user traffic to the ISE PSNs will be over the gig1 interface which will be addressed from another L3 network. Is this a supported configuration in ISE?
    I intend to use the DHCP probe as part of device profiling and will ideally like to have just an additional ip helper to add to our switch SVI config. Also, it will appear that WLCs can only be configured for 2 DHCP servers for a given network so another consideration for when we bringing our WLAN in scope. We however use ACE load balancers within our DC and from what I have read, they do not support DHCP load balancing. Are there any workarounds to using the DHCP probe with multiple PSNs without having to add each node as an ip helper/DHCP server on the NADs?
    Thanks in advance
    Sayre

    Hello Sayre-
    For Question #1:
    Management is restricted to GigabitEthernet 0 and that cannot be changed so you should be good there
    You can configure Radius and Profiling to be enabled on other interfaces
    Even though you are not using guest services yet, you can dedicate an interface just for that. As a result, you can separate guest traffic completely from your production network
    Take a look at this link for more info:
    http://www.cisco.com/c/en/us/td/docs/security/ise/1-2/installation_guide/ise_ig/ise_app_c-ports.html
    For Question #2
    If you are using a Cisco WLC and running code 7.4 and newer you don't need to mess with the IP helper configurations. 
    The controller can be configured to act as a collector for client profiling and interact with the DHCP thread along with the RADIUS accounting task that is running on the controller. The controller receives a copy of the DHCP request packet sent from the DHCP thread and parses the DHCP packet for two options:
    –Option 12—HostName of the client
    –Option 60—The Vendor Class Identifier
    After this information is gathered from the DHCP_REQUEST packet, a message is formed by the controller with these option fields and is sent to the RADIUS accounting thread, which is in turn transmitted to the ISE in the form of an interim accounting message.
    Both DHCP and HTTP profiling settings are located under the "Advanced" configuration tab in the WLC
    On the other hand, you can also use Anycast for profiling. You can check out some of Cisco Live's sessions for more info on that. Here is one that is from a couple of years (There are more recent ones that are available as well):
    http://www.alcatron.net/Cisco%20Live%202013%20Melbourne/Cisco%20Live%20Content/Security/BRKSEC-3040%20%20Advanced%20ISE%20and%20Secure%20Access%20Deployment.pdf
    I hope this helps!
    Thank you for rating helpful posts!

  • Casting in ABAP Objects

    Why the cast error generates only in Widening cast?

    Hi Shyam,
    WELCOME TO SDN!!!
    Please check this link
    http://abapprogramming.blogspot.com/2007/10/oops-abap-8.html
    The widening cast in this case does not cause an error because the reference airplane actually points to an instance in the subclass lcl_cargo_airplane. The dynamic type is therefore u2018REF TO lcl_cargo_airplaneu2019.
    Here the widening cast produces the MOVE_CAST_ERROR runtime error that can be caught with u201CCATCH ... ENDCATCHu201D, because the airplane reference does not point to an instance in the subclass lcl_cargo_airplane, but to a u201Cgeneral airplane objectu201D. Its dynamic type is therefore u2018REF TO lcl_airplaneu2019 and does not correspond to the reference type cargo_airplane.
    The widening cast logically represents the opposite of the narrowing cast. The widening cast cannot be checked statically, only at runtime. The Cast Operator u201C?=u201D (or the equivalent u201CMOVE ... ?TO u2026u201D) must be used to make this visible.
    With this kind of cast, a check is carried out at runtime to ensure that the current content of the source variable corresponds to the type requirements of the target variables. In this case therefore, it checks that the dynamic type of the source reference airplane is compatible with the static type of the target reference cargo_airplane. If it is, the assignment is carried out. Otherwise the catchable runtime error u201CMOVE_CAST_ERRORu201D occurs, and the original value of the target variable remains the same.
    Best regards,
    raam

  • Can not cast from object to int

    Hi All,
    I have the following bunch of code
    Session session;
              session = getSessionFactory().openSession();
              Query query;
              int MaxPageId = 0;
              List list;
              try{
                   query = session.createQuery("select max(emp.id) from EmpBean emp");
                   list = query.list();
                   MaxPageId = (int) list.get(0);
                   return MaxPageId;
              catch(Exception e){
                   System.out.println(e.getMessage());
              return MaxPageId;
    The query executed successfully but when i get the max id in a integer variable by the following statement
    MaxPageId = (int) list.get(0);
    I get the following error "can not cast from object to int"
    Please suggest for the same.
    -Thanks

    Cast to an Integer, not an int, and let autoboxing turn the Integer into an int.
    int maxPageId;
    maxPageId = (Integer) list.get(0);You can't cast objects into primitives.
    Autoboxing isn't casting.
    And use Java naming conventions. Local variables start with a lower-case letter.

  • How to cast a column of a derived column in a view to NULL

    I have a derived column in my view and this column by default is picked up as not null.
    I want to cast it to null how can i do it ?
    Actual column
    column1 varchar(3) not null
    Expected column
    column1 varchar(3)  null
    Mudassar

    Shridar I  havent defined it but the derived column has been picked up as not null which is strange
    CREATE VIEW test
    AS
    SELECT 
    CASE
    WHEN COMPANY_SIZE IS NULL then  'a'
    ELSE 'b' 
    END AS
    column1 ----- added derived column identifier
    ,[Company_Size] AS [CompanySize]
    FROM xyz
    Mudassar

  • Oracle Arrays and getVendorConnection API and Class Cast Exception

    I 've gone through various threads relating to the topic of Oracle Arrays and the getVendorConnecton API call to avoid the class Cast Exception.. i ve used all these but am still facing the problem...
    I would appreciate it if some one could resolve the following queries :
    I am using Weblogic 8.1 SP5 with oracle 8i
    1. I read that the need to use the getVendorConnection API to make pl/sql proc calls with oracle arrays from the WL Server wont be required to avoid classCastException...
    I tried to use the connection from the WL connection pool ..but it didnot work....I used the getVendorConnection API ..which also doesnot seem to work..
    I got the Heurisitc Hazard exception...I used the Oracle 9i driver ie ojdbc14.jar ...after this the exception is not coming but still the code doesnt seem to work...
    the snippet of the code is pasted below :
    ~~~~~~~~~~~~~~~~~~~~~~~code is : ~~~~~~~~~~~~~~~~~~~
    /*below :
    logicalCon is the Connection from the WL connection pool
    JDBCcon is the JDBC connection. */
    <div> try </div>
    <div>{ </div>
    <div>
    <b>vendorConn</b> = ((WLConnection)logicalCon).getVendorConnection();
    </div>
    <div>
    //Calling the procedure
    </div>
    <div>
    //java.util.Map childMap1 = JDBCcon.getTypeMap();
    </div>
    <div>
    java.util.Map childMap1 = <b>vendorConn</b>.getTypeMap();
    </div>
    <div>
    childMap1.put("SST_ROUTE_ENTRY", Class.forName("svm.stport.ejb.StaticRouteEntry"));
    </div>
    <div>
    //JDBCcon.setTypeMap(childMap1);
    <b>vendorConn</b>.setTypeMap(childMap1);
    </div>
    <div>
    // Create an oracle.sql.ARRAY object to hold the values
    </div>
    <div>
    /*oracle.sql.ArrayDescriptor arrayDesc1 = oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", JDBCcon); */
    </div>
    <div>
    oracle.sql.ArrayDescriptor arrayDesc1 =
    oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", <b>vendorConn</b>); // here if i use the JDBCcon it works perfectly.... <u>^%^%^%</u>
    </div>
    <div>
    code to fill in the sst route entry array....
    .....arrayValues1 */
    </div>
    <div>
    /* oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, JDBCcon, arrayValues1); */
    </div>
    <div>
    oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, <b>vendorConn</b>, arrayValues1);
    </div>
    <div>
    callStatement = logicalCon.prepareCall( "? = call procName(?, ?, ?)");
    </div>
    <div>
    /* ..code to set the ?s ie array1 */
    </div>
    <div>
    callStatement.execute();
    </div>
    <div>
    }catch(Exceptio e){
    </div>
    <div>
    }</div>
    <div>
    finally </div>
    </div>{</div>
    <div>System.out.println(" I ve come to finally"); </div>
    <div>}</div>
    <div>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~code snippet ends here ~~~~~~~~~~~~~~``
    </div>
    I have observed that the control immediately comes to the finally block after the call to the createDescriptor line above with <u>^%^%^%</u> in the comment. If i use the JDBCCon in this line...it works perfectly fine.
    Any pointers to where anything is getting wrong.
    I have jst set the vendorCon to null in the end of the file and not closed it. Subsequently i have closed the logicalCon. This has been mentioned in some of the thread in this forum also.
    Thanks,
    -jw

    Jatinder Wadhwa wrote:
    I 've gone through various threads relating to the topic of Oracle Arrays and the getVendorConnecton API call to avoid the class Cast Exception.. i ve used all these but am still facing the problem...
    I would appreciate it if some one could resolve the following queries :
    I am using Weblogic 8.1 SP5 with oracle 8i
    1. I read that the need to use the getVendorConnection API to make pl/sql proc calls with oracle arrays from the WL Server wont be required to avoid classCastException...
    I tried to use the connection from the WL connection pool ..but it didnot work....I used the getVendorConnection API ..which also doesnot seem to work..
    I got the Heurisitc Hazard exception...I used the Oracle 9i driver ie ojdbc14.jar ...after this the exception is not coming but still the code doesnt seem to work...
    the snippet of the code is pasted below :
    ~~~~~~~~~~~~~~~~~~~~~~~code is : ~~~~~~~~~~~~~~~~~~~Hi. Show me the whole exception and stacktrace if you do:
    try
    vendorConn = ((WLConnection)logicalCon).getVendorConnection();
    java.util.Map childMap1 = vendorConn.getTypeMap();
    childMap1.put("SST_ROUTE_ENTRY" Class.forName("svm.stport.ejb.StaticRouteEntry"));
    vendorConn.setTypeMap(childMap1);
    oracle.sql.ArrayDescriptor arrayDesc1 =
    oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR",
    vendorConn);
    oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, vendorConn, arrayValues1);
    callStatement = logicalCon.prepareCall( "? = call procName(? ? ?)");
    callStatement.execute();
    }catch(Exception e){
    e.printStackTrace();
    finally
    try{logicalCon.close();}catch(Exception ignore){}
    System.out.println(" I ve come to finally");
    /*below :
    logicalCon is the Connection from the WL connection pool
    JDBCcon is the JDBC connection. */
    <div> try </div>
    <div>{ </div>
    <div>
    <b>vendorConn</b> = ((WLConnection)logicalCon).getVendorConnection();
    </div>
    <div>
    //Calling the procedure
    </div>
    <div>
    //java.util.Map childMap1 = JDBCcon.getTypeMap();
    </div>
    <div>
    java.util.Map childMap1 = <b>vendorConn</b>.getTypeMap();
    </div>
    <div>
    childMap1.put("SST_ROUTE_ENTRY", Class.forName("svm.stport.ejb.StaticRouteEntry"));
    </div>
    <div>
    //JDBCcon.setTypeMap(childMap1);
    <b>vendorConn</b>.setTypeMap(childMap1);
    </div>
    <div>
    // Create an oracle.sql.ARRAY object to hold the values
    </div>
    <div>
    /*oracle.sql.ArrayDescriptor arrayDesc1 = oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", JDBCcon); */
    </div>
    <div>
    oracle.sql.ArrayDescriptor arrayDesc1 =
    oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", <b>vendorConn</b>); // here if i use the JDBCcon it works perfectly.... <u>^%^%^%</u>
    </div>
    <div>
    code to fill in the sst route entry array....
    .....arrayValues1 */
    </div>
    <div>
    /* oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, JDBCcon, arrayValues1); */
    </div>
    <div>
    oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, <b>vendorConn</b>, arrayValues1);
    </div>
    <div>
    callStatement = logicalCon.prepareCall( "? = call procName(?, ?, ?)");
    </div>
    <div>
    /* ..code to set the ?s ie array1 */
    </div>
    <div>
    callStatement.execute();
    </div>
    <div>
    }catch(Exceptio e){
    </div>
    <div>
    }</div>
    <div>
    finally </div>
    </div>{</div>
    <div>System.out.println(" I ve come to finally"); </div>
    <div>}</div>
    <div>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~code snippet ends here ~~~~~~~~~~~~~~``
    </div>
    I have observed that the control immediately comes to the finally block after the call to the createDescriptor line above with <u>^%^%^%</u> in the comment. If i use the JDBCCon in this line...it works perfectly fine.
    Any pointers to where anything is getting wrong.
    I have jst set the vendorCon to null in the end of the file and not closed it. Subsequently i have closed the logicalCon. This has been mentioned in some of the thread in this forum also.
    Thanks,
    -jw

Maybe you are looking for