Returning an Object Array

I am unable to figure out the way in which I can return an object
array from a cpp file to java. Is there any obvious error which you can spot in
my CPP file?
When I try to return a single object in the native function,
it works fine but when I try to extend it and return an array of the object, it
throws an error.
Please find below the details
h1. Java Class
public class Flight {
public String ID;
public class InterfaceClass {
private native Flight[] GetFlights();
public static void main(String[] args)
Flight[] objFlight = new
InterfaceClass().GetFlights();
System.+out+.println(objFlight[0].ID);
static {
System.+loadLibrary+("main");
h1. CPP File
JNIEXPORT jobjectArray JNICALL Java_InterfaceClass_GetFlights(JNIEnv env, jobject obj)
//1. ACCESSING THE FLIGHT CLASS
jclass cls_Flight = env->FindClass("LFlight;");
//2. CONSTRUCTOR FOR FLIGHT CLASS
jmethodID mid_Flight = env->GetMethodID(cls_Flight,"<init>", "()V");
//3. CREATING AN OBJECT OF THE FLIGHT CLASS
jobject objFlight = env->NewObject(cls_Flight, mid_Flight);
//4. ACCESSING THE FLIGHT's "ID" FIELD
jfieldID fid_ID = env->GetFieldID(cls_Flight, "ID","Ljava/lang/String;");
//5. SETTING THE VALUE TO THE FLIGHT's "ID" FIELD
env->SetObjectField(objFlight,fid_ID, env->NewStringUTF("ABC"));
//6. ACCESSING THE FLIGHT ARRAY CLASS
jclass cls_Flight_Array = env->FindClass("[LFlight;");
if(cls_Flight_Array == NULL)
printf("Error-1");
//7. CREATING A NEW FLIGHT ARRAY OF SIZE 1 jobjectArray arrFlightArray = env->NewObjectArray(1,cls_Flight_Array,NULL);
if(arrFlightArray == NULL)
printf("Error-2");
//8. INSERTING A FLIGHT BJECT TO THE ARRAY
env->SetObjectArrayElement(arrFlightArray,0,objFlight);
return arrFlightArray;
h1. Error
# A fatal error has been detected by the Java Runtime Environment:
# EXCEPTION_ACCESS_VIOLATION
(0xc0000005) at pc=0x6d9068d8, pid=1804, tid=3836
# JRE version: 6.0_18-b07
# Java VM: Java HotSpot(TM) Client VM (16.0-b13 mixed mode, sharing
windows-x86
# Problematic frame:
# V [jvm.dll+0x1068d8]
# An error report file with more information is saved as:
# C:\Users\Amrish\Workspace\JNI Test\bin\hs_err_pid1804.log
# If you would like to submit a bug report, please visit:
http://java.sun.com/webapps/bugreport/crash.jsp
C:\Users\Amrish\Workspace\JNI Test\bin>java -Djava.library.path=.
InterfaceClass
Exception in thread "main" java.lang.ArrayStoreException
at
InterfaceClass.GetFlights(Native Method)
at
InterfaceClass.main(InterfaceClass.java:6)
C:\Users\Amrish\Workspace\JNI Test\bin>java -Djava.library.path=.
InterfaceClass
Exception in thread "main" java.lang.ArrayStoreException
at
InterfaceClass.GetFlights(Native Method)
at
InterfaceClass.main(InterfaceClass.java:6)
Edited by: amrish_deep on Mar 18, 2010 7:40 PM
Edited by: amrish_deep on Mar 18, 2010 7:40 PM

//6. ACCESSING THE FLIGHT ARRAY CLASS
jclass cls_Flight_Array = env->FindClass("[LFlight;");The argument to NewObjectArray is the +element+ class of the array you're about to create, not the +array+ class itself.

Similar Messages

  • Calling a method that returns an object Array

    Hello.
    During a JNICALL , I wish to call a method which returns an object array.
    ie my java class has a method of the form
    public MyObject[] getSomeObjects(String aString){
    MyObject[] theObjects=new MyObject[10];
    return theObjects
    Is there an equivalent to (env)->CallObjectMethod(...
    which returns a jobjectArray instead of a jobject, and if not could somebody suggest a way around this.
    Thanks,
    Neil

    I believe an array oj jobjects is also a jobject. You can then cast it to another class.

  • Generated WS client is unable to unmarshal returned object array

    Hello,
    I have created web service using Sun jaxws implementation. Several methods of this ws return object array (CustomObj []). When I generate the client (using jaxws-maven-plugin - wsimport) and call these methods I always get
    empty array. I get no errors or warnings. When I generate axis client all works as expected. I think that this issue is related to jaxb but i have tried to switch between several versions ant this didn't help. CustomObj is very simple object with two attributes name and value...
    Thanks for hints...

    Hi Shepy,
    I think mapping an array of objects as response in WSDL messages is somewhat of an issue.
    Instead try moving this array of object into another XSD if i assume you are using XSDs and then make sure that response XSD holds and array of your objects.
    Regards,
    Anand

  • Returning an object that contains a collection WL 9.2

    Hello,
    I have a class like this:
    public class data {
    private Collection<MyObject> coll; //MyObject is another class
    If I return this object from a web service call, i.e.
    @WebService
    public class HelloWorld {
         @WebMethod
    public data hello() {
    I get an error saying java class MyObject is not known, which makes sense, because I only declared "HelloWorld" to jwsc task.
    How can I make this class known, by annotation etc.?
    Someone suggested to use "IncludeSchema" in the jwsc task, but apparently that has been deprecated.
    Thanks!
    Edited by ghosh007 at 02/21/2008 12:59 PM
    Edited by ghosh007 at 02/21/2008 1:23 PM

    Hi,
    As you have this "Artiicle" class, extend it to be serializable and then define an Array of type Artiicle. So the return type would be an Array of a complex type i.e. Articles. In WSDL there will be type that defines an Array and this type can be used as a return message for your methode.
    Try this, I think it will help you.
    Regards,

  • Returning collection-associative array from pl-sql procedure

    CREATE OR REPLACE procedure test_ganesh( p_deptno IN number,gana out PARTIES_RESULT)
    is
    query varchar2(200);
    PARTY_ID varchar2(200);
    PARTY_CODE varchar2(200);
    PARTY_NAME varchar2(200);
    PARTY_SEQ VARCHAR2(200);
    counter number;
    TYPE PARTIES IS TABLE OF varchar2(2000) index by binary_integer;
    txn_parties PARTIES;
    type PARTIES_RESULT IS TABLE OF PARTIES index by binary_integer;
    total_result PARTIES_RESULT;
    TYPE EmpTyp IS REF CURSOR;
    p_du EmpTyp;
    p_cursor EmpTyp;
    global_counter number;
    begin
    global_counter:=1;
    counter:=1;
    open p_cursor FOR
    select A.ref_no
    from ot_lc_txn_details A
    where rownum <12;
    LOOP
    FETCH p_cursor INTO query;
    EXIT WHEN p_cursor%NOTFOUND;
    counter:=1;
    open p_du FOR
         select party_id,party_code,seq_no,party_name from ot_txn_party where ref_no=query;
         LOOP
         FETCH p_du INTO PARTY_ID,PARTY_CODE,PARTY_SEQ,PARTY_NAME;
         EXIT WHEN p_du%NOTFOUND;
         txn_parties(counter):=PARTY_ID || '&&&' || PARTY_CODE || '&&&'||PARTY_SEQ || '&&&' || PARTY_NAME;
              counter:=counter+1;
         END LOOP;
         CLOSE p_du;
    total_result(global_counter):=txn_parties;
    global_counter:=global_counter+1;
    END LOOP;
    CLOSE p_cursor;
    --open gana FOR SELECT * FROM table(cast(total_result as PARTIES_RESULT)) ;
    end;
    The error comes at line one, PLS-00905- object PARTIES_RESULT is invalid.
    i have used the create type thing to create this type.
    if i remove the out parameter it works, no compilation error.
    Questions i) How to return the associative array as out parameter?
    ii)Am i doing aynthing qrong here?
    iii) Can i open a ref cursor to this associative array and then return that ref_cursor?
    Please anyone reply back, Thanks in advance
    Message was edited by:
    user649602

    As an example:
    SQL> create type PARTIES is table of varchar2(2000);
      2  /
    Type created.
    SQL> create or replace procedure proc1(p_deptno number,gana out parties) as
      2  begin
      3   select ename
      4   bulk collect into gana
      5   from emp
      6   where deptno = p_deptno;
      7  end;
      8  /
    Procedure created.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Java Null Pointer Exception when assigning a value to an Object Array

    I am working on a webservice where the request can contain a dynamic array of SingleOwnerRequestNodeDetail objects. I need to read these objects in and sort them according to an orderNbr that is contained in the object.
    I am attempting to read these object into a Comparable class and sort them. I am having problems when I try to insert the objects into my object array ComparableBO[]. I get the following error: Exception during processing: java.lang.NullPointerException
    Any assistance would be greatly appreciated.
    Here's my class:
    public class ComparatorBO  implements Comparable {
         private SingleOwnerRequestNodeDetail nodeDetailInfo;
         private int orderNbr;
         public SingleOwnerRequestNodeDetail getNodeDetailInfo() {
              return nodeDetailInfo;
         public void setNodeDetailInfo(SingleOwnerRequestNodeDetail nodeDetailInfo) {
              this.nodeDetailInfo = nodeDetailInfo;
         public int getOrderNbr() {
              return Integer.parseInt(nodeDetailInfo.getSingleOwnerRequestOrderNbr());
         public void setOrderNbr (int orderNbr) {
              this.orderNbr = orderNbr;
         public int compareTo(Object anotherNodeDetailInfo)throws ClassCastException {
              if (!(anotherNodeDetailInfo instanceof ComparatorBO))
                   throw new ClassCastException ("An single owner request node detail object is expected");
              int anotherNodeDetailOrderNbr = ((ComparatorBO)anotherNodeDetailInfo).getOrderNbr();
              return this.orderNbr - anotherNodeDetailOrderNbr;
    }Here's the code where I read in the objects and attempt to place them in the comparableBO[]
    ComparatorBO[] comparatorBOArray = null;
    comparatorBOArray = new ComparatorBO[requestInfo.length];
              for (int i=0; i < requestInfo.length; i++)
                   SingleOwnerRequestNodeDetail nodes = new SingleOwnerRequestNodeDetail();
                   ComparatorBO comparatorBO = new ComparatorBO();
                   nodes.setSingleOwnerRequestNodeID(requestInfo.getSingleOwnerRequestNodeID());
                   nodes.setSingleOwnerRequestNodeType(requestInfo[i].getSingleOwnerRequestNodeType());
                   nodes.setSingleOwnerRequestOpCode(requestInfo[i].getSingleOwnerRequestOpCode());
                   nodes.setSingleOwnerRequestOrderNbr(requestInfo[i].getSingleOwnerRequestOrderNbr());
                   comparatorBO.setNodeDetailInfo(nodes);                         
                   *comparatorBOArray[i].setNodeDetailInfo(comparatorBO.getNodeDetailInfo());*
                   comparatorBOArray[i].setOrderNbr(Integer.parseInt(nodes.getSingleOwnerRequestOrderNbr()));

    imadeveloper wrote:
    I am working on a webservice where the request can contain a dynamic array of SingleOwnerRequestNodeDetail objects. I need to read these objects in and sort them according to an orderNbr that is contained in the object.
    I am attempting to read these object into a Comparable class and sort them. I am having problems when I try to insert the objects into my object array ComparableBO[]. I get the following error: Exception during processing: java.lang.NullPointerException
    Any assistance would be greatly appreciated.
    Here's my class:
    public class ComparatorBO  implements Comparable {
         private SingleOwnerRequestNodeDetail nodeDetailInfo;
         private int orderNbr;
         public SingleOwnerRequestNodeDetail getNodeDetailInfo() {
              return nodeDetailInfo;
         public void setNodeDetailInfo(SingleOwnerRequestNodeDetail nodeDetailInfo) {
              this.nodeDetailInfo = nodeDetailInfo;
         public int getOrderNbr() {
              return Integer.parseInt(nodeDetailInfo.getSingleOwnerRequestOrderNbr());
         public void setOrderNbr (int orderNbr) {
              this.orderNbr = orderNbr;
         public int compareTo(Object anotherNodeDetailInfo)throws ClassCastException {
              if (!(anotherNodeDetailInfo instanceof ComparatorBO))
                   throw new ClassCastException ("An single owner request node detail object is expected");
              int anotherNodeDetailOrderNbr = ((ComparatorBO)anotherNodeDetailInfo).getOrderNbr();
              return this.orderNbr - anotherNodeDetailOrderNbr;
    }Here's the code where I read in the objects and attempt to place them in the comparableBO[]
    ComparatorBO[] comparatorBOArray = null;
    comparatorBOArray = new ComparatorBO[requestInfo.length];
              for (int i=0; i < requestInfo.length; i++)
                   SingleOwnerRequestNodeDetail nodes = new SingleOwnerRequestNodeDetail();
                   ComparatorBO comparatorBO = new ComparatorBO();
                   nodes.setSingleOwnerRequestNodeID(requestInfo.getSingleOwnerRequestNodeID());
                   nodes.setSingleOwnerRequestNodeType(requestInfo[i].getSingleOwnerRequestNodeType());
                   nodes.setSingleOwnerRequestOpCode(requestInfo[i].getSingleOwnerRequestOpCode());
                   nodes.setSingleOwnerRequestOrderNbr(requestInfo[i].getSingleOwnerRequestOrderNbr());
                   comparatorBO.setNodeDetailInfo(nodes);                         
                   *comparatorBOArray[i].setNodeDetailInfo(comparatorBO.getNodeDetailInfo());*
                   comparatorBOArray[i].setOrderNbr(Integer.parseInt(nodes.getSingleOwnerRequestOrderNbr()));
    Well normally when someone wont tell me what line the error occured in I copy paste their code into my compiler and find out. But you have other classes which you have not shown us so I cannot help you.
    Incase you missed my point, please tell us where the error occured!

  • Object Array problem in Websphere WebServices

    Hi,
    Can someone help me out with a situation that I am stuck with in WebServices.
    I have a WebService which returns a DTO which has a getter and setter for an array of another type of DTO object.
    Sample:-
    public class MyDTO extends AnotherDTO implements Serializable {
    private InnerDTO qcDtoList[] = new InnerDTO[0];
    public MyDTO() {
    public InnerDTO[] getQcDtoList() {
    return qcDtoList;
    public void setQcDtoList(InnerDTO[] resEDXDTOs) {
    qcDtoList = resEDXDTOs;
    But when I generate the WSDL for the webservice using WSAD 5.1 that uses the above DTO, the server side generated skeleton file looks like:-
    public class MyDTO extends AnotherDTO implements java.io.Serializable {
    private InnerDTO[] qcDtoList;
    public MyDTO() {
    public InnerDTO[] getQcDtoList() {
    return qcDtoList;
    public void setQcDtoList(InnerDTO[] qcDtoList) {
    this.qcDtoList = qcDtoList;
    As you can see from above, my initialization info is not available in the generated skeleton. I also tried putting the initialization in the constructor, with no effect.
    What could be the reason for this? And is it possible to initialize my InnerDTO without losing it in the generated skeleton?
    I simply want to initialize the object array.
    If I need to modify my WSDL, what additional annotations should I add on the WSDL to get the desired effect?
    I use WSAD's (Websphere Studio App Developer) IBM Websphere Webservices protocol and the JDK version is 1.3.1 and WSAD version is 5.1.
    I would really appreciate if you can throw light on this?
    Thanx and Regds,
    Prashanth.

    Thank you for the quick response. I looked at the example you suggested and made the following changes. Now I'm receiving an "Invalid datatype" error on the "SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer))" statement. I must be missing something simple and I just can't put my finger on it.
    PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
    v_categories IN ARCHIVE.integer_aat,
    rs OUT RSType)
    AS
    /* PURPOSE: Return Search Results for the Category and Keyword Provided
    VARIABLES:
    v_categories = Document Categories array entered
    v_term = Keyword entered
    rs = Result Set
    TYPE tbl_integer IS TABLE OF INTEGER;
    tbl_cat tbl_integer;
    BEGIN
    FOR i IN 1 .. v_categories.COUNT
    LOOP
    tbl_cat.EXTEND(1);
    tbl_cat(i) := v_categories(i);
    END LOOP;
    OPEN rs FOR
    SELECT A.ID,
    B.CATEGORY,
    A.FILENAME,
    A.DISPLAY_NAME,
    A.COMMENTS
    FROM TBL_ARCHIVE_DOCUMENTS A,
    TBL_ARCHIVE_DOC_CAT B,
    TBL_ARCHIVE_DOC_KEYWORDS C
    WHERE A.ID = B.ID
    AND A.ID = C.ID
    AND B.CATEGORY IN (SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer)))
    AND C.KEYWORD = v_term
    ORDER BY A.ID;
    END SEL_SEARCH_RESULTS;

  • Problem in returning the object + reflection + hashMap + list

    Hi All,
    i am very new to java forums...
    i'm sorry to disturb you all.. i don't exaclty know how to raise a question in forums..
    Here my query is ::::
    i have xlsReader file,which will read the data from the xls file.
    after reading it,i am adding the contents of the xls sheet in to a Arraylist.
    then i've put the list contents in to an object array,
    then i'm invoking the getter and setter method of the javabean class.
    and i'm returning object,but object contains only the last data of the list,instead of whole contents in that object.
    the code is here,where am returnung the object.
    kindly do reply...
    Thanks in advance...:)
    public static Object setDynamicValue ( Method setter2, List columnData, Object obj2 , Method getter2 )
    Object val2=null;
    try {
    for ( int i = 0 ; i < columnData.size() ; i++ ) {
    Object obj[] =( Object [] )columnData.get(i);
    for ( int j = 0; j < obj.length; j++) {
    // System.out.println("column Data:pppp: :"+obj[j].toString());
    setter2.invoke(obj2, new Object[] {obj[j].toString() });
    val2 = getter2.invoke(obj2, new Object[0]);
    //System.out.println("output:::"+val2.toString());
    // return val2;
    System.out.println("#########################");
    }catch (IllegalAccessException e) {
    System.out.println("IllegalAccessException came :::"+e);
    } catch (IllegalArgumentException e) {
    // TODO Auto-generated catch block
    System.out.println("IllegalArgumentException came :::"+e);
    e.printStackTrace();
    } catch (InvocationTargetException e) {
    System.out.println("InvocationTargetException came :::"+e);
    // TODO Auto-generated catch block
    e.printStackTrace();
    return val2;
    here,we are returning the object val2 , but its printing only the last data of the list
    Object o1 = setDynamicValue ( setter2, columnName ,columnData, obj2,getter2 );
    System.out.println("lastvalue of the list :"+o1);
    thanks...
    plz reply..

    You are getting only the last data of the list because you does not have any mechanism to hold other values.
    Check inf your code your the following code in the inner for loop (loop with index j)
    val2 = getter2.invoke(obj2, new Object[0]);
    Even if you are capturing some value into val2, it gets replaced next time the body of for loop runs. This way you are getting only the last data.
    If you want to capture all values use arraylist. Keep adding all values to arraylist and return it. While printing iterate over arraylist and print values.
    This is not a problem related to reflection or hashMap. Just the logic you have written is incorrect.

  • How To Load SINGLE CELL Value as Object - In 2D Object Array - InvalidCastException

    Setup: ---- VB.net - Visual Studio 2010 - Excel Version 2010 - Option Strict ON
    The following WORKS FINE all day long for loading MULTIPLE range values IE: ("F2:F5") or more into a 2D Object Array... No problem... as in the following..
    Dim myRangeTwo As Range = ws.Range("F2:F5")  ' MULTIPLE CELL RANGE     
    Dim arr2(,) As Object = CType(myRangeTwo.Value(XlRangeValueDataType.xlRangeValueDefault), Object(,))
    The ws.range("F2:F5") values are stuffed into the myRangeTwo range variable as 2D Objects and then those are easily stuffed into the 2D object array...
    But this does not work for a SINGLE cell range...
    Dim myRangeTwo As Range = ws.Range("F2:F2")    ' SINGLE CELL RANGE F2 ONLY            
    Dim arr2(,) As Object = CType(myRangeTwo.Value(XlRangeValueDataType.xlRangeValueDefault), Object(,))
    This triggers an Invalid Cast Exception error on trying to load into the arr2(,).. because the ws.range("F2:F2") is stuffed into the myRangeTwo variable as a "string"
    not as an object therefore is not possible to stuff it into an Object Array and so correctly causes the Invalid Cast Error...
    How do you handle this seemingly ridiculously simple problem ??
    thanks... Cj

    Hello,
    Simply answer, you need to determine if the range is a single cell or multiple cells. So the following is geared for returning a DataTable for a start and end cell addresses that are different, granted there is no check to see if the cells are valid i.e.
    end cell is before start cell i.e.
    Since B1 and B10 is a valid range we are good but if we pass in F1:F1 or F10:F10 we must make a decision as per the if statement at the start of the function and if I were expecting this to happen I would have another function that returned a single value.
    Option Strict On
    Option Infer On
    Imports Excel = Microsoft.Office.Interop.Excel
    Imports Microsoft.Office
    Imports System.Runtime.InteropServices
    Module ExcelDemoIteratingData_2
    Public Sub DemoGettingDates()
    Dim dt As DataTable = OpenExcelAndIterate(
    IO.Path.Combine(
    AppDomain.CurrentDomain.BaseDirectory,
    "GetDatesFromB.xlsx"),
    "Sheet1",
    "B1",
    "B10")
    Dim SomeDate As Date = #12/1/2013#
    Dim Results =
    From T In dt
    Where Not IsDBNull(T.Item("SomeDate")) AndAlso T.Field(Of Date)("SomeDate") = SomeDate
    Select T
    ).ToList
    If Results.Count > 0 Then
    For Each row As DataRow In Results
    Console.WriteLine("Row [{0}] Value [{1}]",
    row.Field(Of Integer)("Identifier"),
    row.Field(Of Date)("SomeDate").ToShortDateString)
    Next
    End If
    End Sub
    Public Function OpenExcelAndIterate(
    ByVal FileName As String,
    ByVal SheetName As String,
    ByVal StartCell As String,
    ByVal EndCell As String) As DataTable
    If StartCell = EndCell Then
    ' Decide logically what to do or
    ' throw an exception
    End If
    Dim dt As New DataTable
    If IO.File.Exists(FileName) Then
    Dim Proceed As Boolean = False
    Dim xlApp As Excel.Application = Nothing
    Dim xlWorkBooks As Excel.Workbooks = Nothing
    Dim xlWorkBook As Excel.Workbook = Nothing
    Dim xlWorkSheet As Excel.Worksheet = Nothing
    Dim xlWorkSheets As Excel.Sheets = Nothing
    Dim xlCells As Excel.Range = Nothing
    xlApp = New Excel.Application
    xlApp.DisplayAlerts = False
    xlWorkBooks = xlApp.Workbooks
    xlWorkBook = xlWorkBooks.Open(FileName)
    xlApp.Visible = False
    xlWorkSheets = xlWorkBook.Sheets
    ' For/Next finds our sheet
    For x As Integer = 1 To xlWorkSheets.Count
    xlWorkSheet = CType(xlWorkSheets(x), Excel.Worksheet)
    If xlWorkSheet.Name = SheetName Then
    Proceed = True
    Exit For
    End If
    Runtime.InteropServices.Marshal.FinalReleaseComObject(xlWorkSheet)
    xlWorkSheet = Nothing
    Next
    If Proceed Then
    dt.Columns.AddRange(
    New DataColumn() _
    New DataColumn With {.ColumnName = "Identifier", .DataType = GetType(Int32), .AutoIncrement = True, .AutoIncrementSeed = 1},
    New DataColumn With {.ColumnName = "SomeDate", .DataType = GetType(Date)}
    Dim xlUsedRange = xlWorkSheet.Range(StartCell, EndCell)
    Try
    Dim ExcelArray(,) As Object = CType(xlUsedRange.Value(Excel.XlRangeValueDataType.xlRangeValueDefault), Object(,))
    If ExcelArray IsNot Nothing Then
    ' Get bounds of the array.
    Dim bound0 As Integer = ExcelArray.GetUpperBound(0)
    Dim bound1 As Integer = ExcelArray.GetUpperBound(1)
    For j As Integer = 1 To bound0
    If (ExcelArray(j, 1) IsNot Nothing) Then
    dt.Rows.Add(New Object() {Nothing, ExcelArray(j, 1)})
    Else
    dt.Rows.Add(New Object() {Nothing, Nothing})
    End If
    Next
    End If
    Finally
    ReleaseComObject(xlUsedRange)
    End Try
    Else
    MessageBox.Show(SheetName & " not found.")
    End If
    xlWorkBook.Close()
    xlApp.UserControl = True
    xlApp.Quit()
    ReleaseComObject(xlCells)
    ReleaseComObject(xlWorkSheets)
    ReleaseComObject(xlWorkSheet)
    ReleaseComObject(xlWorkBook)
    ReleaseComObject(xlWorkBooks)
    ReleaseComObject(xlApp)
    Else
    MessageBox.Show("'" & FileName & "' not located. Try one of the write examples first.")
    End If
    Return dt
    End Function
    Private Sub ReleaseComObject(ByVal sender As Object)
    Try
    If sender IsNot Nothing Then
    System.Runtime.InteropServices.Marshal.ReleaseComObject(sender)
    sender = Nothing
    End If
    Catch ex As Exception
    sender = Nothing
    End Try
    End Sub
    End Module
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • Why would different CF servers return different objects?

    My application fails (error 1009) when it retrieves an object
    from our ColdFusion production server but works fine when it
    retrieves the same object from our testing server. From the
    ColdFusion side the generated objects appear to be identical. From
    the Flex side the returned objects appear to be different.
    Here is a comparison of the returned objects when dumped with
    objectUtil.getClassInfo:
    From TEST server:.................................From
    PRODUCTION Server
    (Object)#0..............................................(Object)#0.
    ..alias.=."PROJ.cfc.ORDERS"....................alias.=."".
    ..dynamic.=.false.....................................dynamic.=.true.
    ..metadata.=.(Object)#1............................metadata.=.(null).
    ....COMMENTS.=.(Object)#2..
    ......Bindable.=.(Object)#3..
    ........event.=."propertyChange"..
    ....CURR_DOB.=.(Object)#4..
    ......Bindable.=.(Object)#5..
    ........event.=."propertyChange"..
    ....etc.......
    .name.=."cfc::ORDERS".......................name.=."Object".
    ..properties.=.(Array)#86.......................properties.=.(Array)#1.
    ....[0].(QName)#87.................................[0].(QName)#2.
    ......localName.=."COMMENTS"..............localName.=."COMMENTS".
    ......uri.=.""...............................................uri.=."".
    ....[1].(QName)#88.................................[1].(QName)#3.
    ......localName.=."CURR_DOB"................localName.=."CURR_DOB".
    ......uri.=.""..............................................uri.=.""
    etc.
    As you can see, one has an alias, a name and metadata and the
    other doesn't. One is dynamic and the other one isn't.
    What would cause the different servers to return different
    objects?
    From what I can see the servers are identical (Windows 2003,
    CF version 7.02
    latest hotfixes) as are the files (cfc's and swf).
    Thanks

    FROM sys.dm_db_index_physical_stats (null, null, null, null, null )as ts
    See MSDN sys.dm_db_index_physical_stats
    ;  the first parameter is the database id; if you pass NULL as here, then all databases will be scanned, also your offline one.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Object array type casting?

    Hi. I still can't get the hang of array type casting. Is it possible to type caste an array of objects? I tried the following
    LabelledPanel[] comp = (LabelledPanel[])(content.getComponents());
    in my program and I got the ClassCastException.
    Exception occurred during event dispatching:
    java.lang.ClassCastException: [Ljava.awt.Component;
    LabelledPanel is a descendent of JPanel and getComponents() supposed to return Component[]

    java does support casting with arrays. The following code will work:
    String [] strings = new String[] { "1", "2" };
    Comparable [] comps = (Comparable[])strings;
    Object [] objects = (Object [])strings;That is, you can cast following the normal rules of assignment. You are having problems because your casting violates the normal rules of assignment- you're trying to cast a type into a differnt type that it does not extend or implement.
    the toArray() in the Collections API really has nothing to do with casting. That method converts the current Collection into an array of the same type. Since all arrays extend java.lang.Object, it returns the new array as an Object, which you then cast into the specific type.
    You may want to read the language guidlines on casting if you are having problems with it:
    http://java.sun.com/docs/books/jls/second_edition/html/jIX.fm.html
    you can also look at the documenation for Class.isAssignableFrom , which explains casting more briefly.

  • Fill and object array

    I have too many books and not enough understanding on this subject.
    I am trying to fill an object type array with values and am totally confused. In my application, I successfully create a constructor in one file and test the object with some values in another file. I have two objects for employee and would like to place the object values into an object array. There is plenty of information on int[] arrays, but little on object arrays.
    After I can do the array fill:
    I would like to provide object values with JOptionPane.
    Change the print display to show all array elements
    But one thing at a time.
    I was thinking that objects exist first, then are loaded or filled into an object array. I seem to misunderstand as I am not performing the array fill very well. Following a book example seems to confuse me only more.
    Thank you
    //emp.java
    import java.util.*;
    public class Emp {
       private int id;
       private String name;
       private double salary;
       public Emp(int ident, String nm, double sal) {
         id = ident;
         name = nm;
         salary = sal;
       // method raise salary by 5 percent
       double raise() { return salary * 1.05;} // ends raise method
       // setters and getters
       public String getName()              { return(name); }
       public double getSalary()            { return(salary); }
       public int getID()                   { return(id); }
       public void setName(String nm)       { name = nm; }
       public void setSalary(double sal)    { salary = sal; }
       public void setID(int ident)         { id = ident; }
    }The test file
    //EmpTest.java
    import javax.swing.JOptionPane;
    public class EmpTest {
       public static void main(String[] args_) {
                 // Create object based on EmployeeTest2 class
                 // to add employee data to the array called empArray
                 Emp emp1 = new Emp(1,"Smith",2000);
                 Emp emp2 = new Emp(2,"Jones",2500);
                 //test and confirm the objects emp1 and emp2
                     int i;
                     String n;
                     double s;
                     double newsal;
                     // get the salary after the 5 percent raise
                     i = emp1.getID();
                     n = emp1.getName();
                     s = emp1.getSalary();
                     newsal = emp1.raise();
                     System.out.println("object Employee 1 ID: " + i + " Name: " + n + " Old Salary: " + s + " New salary: " + newsal);
                     i = emp2.getID();
                     n = emp2.getName();
                     s = emp2.getSalary();
                     newsal = emp2.raise();
                     System.out.println("object Employee 2 ID: " + i + " Name: " + n + " Old Salary: " + s + " New salary: " + newsal);
         // get the number of employees with JOptionPane
         String employeeCountString = JOptionPane.showInputDialog(
             "Employee Database " +
             "\nEnter the number of employees: ");
         // convert into an integer empcount
         int employeeCount = Integer.parseInt(employeeCountString);
         // initialize the empArray.
         Employee2[] empArray = new Employee2[employeeCount];
         fill(empArray);
         printContents(empArray);
       } //end main method
       private static void fill(Object[] my_arr) {
           int i;
           for (i = 0; i < my_arr.length; i = i + 1) {
         // get the name from the keyboard
         String employeeName = JOptionPane.showInputDialog(
             "Enter the employee name: ");
             // do something here to set the array element to employeeName
         // get the salary
         String employeeSalaryString = JOptionPane.showInputDialog(
             "Enter the employee monthly salary: ");
         //convert into a double
         double employeeSalary = Double.parseDouble(employeeSalaryString);
            //do something here to set array for salary
              my_arr[i] = new Employee2(1,"S1",5); // temporary values here
           } //ends for loop
       } // ends method
       private static void printContents(Object[] the_arr) {
          int i;
          for (i = 0; i < the_arr.length; i = i + 1) {
            System.out.print("Element: " + i);
            //System.out.println(" has the value : " + the_arr);
    System.out.println(" has the value : " + i);
    } //ends for loop
    } // ends printContents method
    } // ends EmpTest class

    what's the matter ?
    Try this :
    import javax.swing.JOptionPane;
    public class EmpTest {
         public static void main(String[] args_) {
              // Create object based on EmployeeTest2 class
              // to add employee data to the array called empArray
              Emp emp1 = new Emp(1, "Smith", 2000);
              Emp emp2 = new Emp(2, "Jones", 2500);
              // test and confirm the objects emp1 and emp2
              int i;
              String n;
              double s;
              double newsal;
              // get the salary after the 5 percent raise
              i = emp1.getID();
              n = emp1.getName();
              s = emp1.getSalary();
              newsal = emp1.raise();
              System.out.println("object Employee 1 ID: " + i + " Name: " + n + " Old Salary: " + s + " New salary: "
                        + newsal);
              i = emp2.getID();
              n = emp2.getName();
              s = emp2.getSalary();
              newsal = emp2.raise();
              System.out.println("object Employee 2 ID: " + i + " Name: " + n + " Old Salary: " + s + " New salary: "
                        + newsal);
              // get the number of employees with JOptionPane
              String employeeCountString = JOptionPane.showInputDialog("Employee Database "
                        + "\nEnter the number of employees: ");
              // convert into an integer empcount
              int employeeCount = Integer.parseInt(employeeCountString);
              // initialize the empArray.
              Emp[] empArray = new Emp[employeeCount];
              fill(empArray);
              printContents(empArray);
         } // end main method
         private static void fill(Object[] my_arr) {
              int i;
              for (i = 0; i < my_arr.length; i = i + 1) {
                   // get the name from the keyboard
                   String employeeName = JOptionPane.showInputDialog("Enter the employee name: ");
                   // do something here to set the array element to employeeName
                   // get the salary
                   String employeeSalaryString = JOptionPane.showInputDialog("Enter the employee monthly salary: ");
                   // convert into a double
                   double employeeSalary = Double.parseDouble(employeeSalaryString);
                   // do something here to set array for salary
                   my_arr[i] = new Emp(1, employeeName, employeeSalary); // temporary values here
              } // ends for loop
         } // ends method
         private static void printContents(Object[] the_arr) {
              int i;
              for (i = 0; i < the_arr.length; i++) {
                   System.out.print("Element # "+i+" Name= "+ ((Emp)the_arr).getName());
                   System.out.print("Salary # "+i+" Salary = "+ ((Emp)the_arr[i]).getSalary());
              } // ends for loop
         } // ends printContents method
    } // ends EmpTest class

  • Search in object array

    I am working on a program in which one of the problems is to search an object array to allow a user to edit an item in the array. I have examples on how to do linear and binary searches, but they are all simple strings of numeric data. How do I apply this algorithm to a more complex array?I have a class file called Application that contains my constructor, and my get & set methods for creating the objects in the array. And I have a driver class to allow a user to view the array, add items to it , and edit items in it.
    This is an example of my declaration of the initial items:
    Application inventory[] = new Application[100];
      inventory[0] = new Application("Jumpstart Toddlers", 14.99, 500);
      inventory[1] = new Application("Norton Antivirus 2003", 49.99, 1200);
      etc....
    I would like to set it up so that the user is prompted for the name of the software item they would like to edit, the array is searched using a method which returns the index the name was found in.

    Sounds like a homework assignment to me but...
    Appliction apps[] = new Application[100];
    ...Add Items to the apps array...
    String software_to_search_for = .. user entered
    data....
    for (int i = 0; i < apps.length; ++i)
    if
    f
    (apps.getSoftware().equalsIgnoreCase(software_to_sea
    ch_for))
    edit(apps[i], software_to_search_for);
    public void edit(Application app, String newName)
    // You can do anything here
    app.setName(newName);
    } // edit
    True enough, this is an assignment. But..These assignments were given to us without all the necessary tools. They are set up by the dept. and we have to finish them even if the instructor does not finish covering all the relevant material.In this case, we have not covered the equalsIgnoreCase(something obviously necessary for my problem). Now that I know what I am looking for, I have found it in my book and can apply it to my code appropriately. I was not necessarily looking for code, just the tools I need for my own design. This is something that the Computer dept. allows for in that they have assistants in the open labs that will help in this manner. Problem is, everyone has been out for Thanksgiving since Tues. Please dont feel as though you assisted someone in cheating!! I can assure you, that is not the case here. Thank you for your help.

  • How can i return an object isn't java object from webservice????

    Hi !
    I have a problem in my Project. When i call method return a java object from webservice , it 's too easy. But when i create my own object (ex:ClientRequest.class) , it doesn't work exactly T_T . When i return that object (on client, doesn't have ClientRequest.class) , i cann't access its static variables.
    How can i do it ??
    Please help me !
    Thanks a lot !!!!!
    class ClientRequest {
    public static int i;
    public static String s;
    public ClientRequest() {
    }

    You can use REFCURSOR type for this. In java SQL TYPES this is available too. In your PLSQL use REFCURSOR for that array and then take the same from java code. Look in the servelet programming book for this SQLTYPE and see PLSQL for handling refcursors. We have done this way and it works.

  • Table with object array data provider

    hi!
    i use the studio creator table and want to fill it with an object array data provider!
    i have an array and the getter:
      public TanData[] getTanDataArray()
            return tanDataArray;    
        }i choosed this for the data provider and in table layout i choose the dataprovider, but when i run my application there are no datas found although the array isn't empty!

    maybe this is a problem:
    i got my data from a database table and i store it in a vector.
    in the example they have a class WeekBean and they fill their array with
       WeekBean[] weeks = {
                new WeekBean(1),
                new WeekBean(2),
                new WeekBean(3),
                new WeekBean(4)
            };and i tried to do this:
        private Vector<TanData> tanDataList = new Vector();
        private TanData[] tanDataArray;
       getTanDataList().copyInto(tanDataArray);could it be that that isn't correct?

Maybe you are looking for

  • Firefox 3.6.4 in XP doesn't respond 1 or 2 links into a Web site home page

    == Issue == Firefox is having problems with certain web sites == Description == Today Firefox was updated to 3.6.4 on my IBM T23 laptop running XP Pro. It now hangs and does not respond after clicking on a link in my.yahoo.com, and www. bloomberg.com

  • Classic freezes or stalls when started in OS X 10.4.6

    Hello, The classic environment freezes or stalls when it is started from OS X 10.4.6. In the expanded classic window pane, the smiling mac on the grey background appears, then the "welcome to Mac OS" appears (Mac OS 9.1). The blue progress bar at the

  • Message in Message Monitor/ RWB stay forever in status DLNG

    Hi, We have a problem with a Message inside our J2EE Adapter. The message remains in the status DLNG forever. We use SAP XI 3.0 Service Stack 13. We have the following scenario: When sending messages via the Oracle JDBC connection to the Receiver-Ser

  • HT1420 how can I deathorize a computer that has been destroyed?

    I had iTunes on a work computer that I had to turn in and it was completely wiped.  I only uninstalled iTunes and I did not deauthorize it.  How can I delete it without having the computer any more?

  • Smartform generates large file attachment

    Hello Everybody, I am having the following issue... I have created a Smartform (one page) and when I email it as a PDF attachment the size of the e-mail is over 400K, which in our case generates and issue because of the number of e-mails that we are