Can i return an Array of Objects from c++ to java ??

hello all,
Can i return an Array of Objects from c++ to java ??
If so how is it possible ??

I suggest you look into the JNI, Java Native Interface. The answer is yes.

Similar Messages

  • Is it possible to return an array of objects from a web service?

    I have been trying to do this for a while now, and I have come to the conclusion that it may be impossible. To demonstate what I want to do I enclose a simple java file [1]. I have deployed this with Axis 2 and I enclose the responce [2], it is obciously not wat I want.
    Is it porrible to do this? If so, how?
    Thanks for any help,
    package org.impress;
    public class SampleObject {
         public SampleElement[] noParameters(){
              SampleElement[] retArray = new SampleElement[2];
              retArray[0] = new SampleElement();
              retArray[0].name = "one";
              retArray[0].value = "alpha";
              retArray[1] = new SampleElement();
              retArray[1].name = "two";
              retArray[1].value = "beta";
              return retArray;
         public class SampleElement {
              public String name;
              public String value;
         <ns:return type="org.impress.SampleObject$SampleElement"/>
         <ns:return type="org.impress.SampleObject$SampleElement"/>

    Can anybody help me with the code of how to return a resultset from a web service. i have put the resultset data's in an object array and tried to return it, but in the client side no data comes ,,, i mean it is printed as null.... and plz tell me where to specify the return type of a object in the wsdl file....

  • Can we return a Array of varchar2 from a function ?

    i have a sql query that returns some rows. I want to define that query inside a function and want to retrieve the results in an array .Finally i want to retrieve those values in array in my .NET runtime . How can i achieve this ?

    bootstrap wrote:
    CREATE OR REPLACE function f_func(dept varchar2) return (what will be return type here ?)As Tubs said - ref cursor.
    Any other choice is likely very wrong.
    select statement...returning a resultset containing more than one rows..Cursors are not result sets. Cursors are not result sets. Repeat this over and over again.
    A cursor is a program. The results from it is the output of the program. There is no so-called result set created in memory containing the output of that cursor.
    The flaw in your approach is to fetch the output of this program, and storing it in very expensive server memory (called the PGA in Oracle) - for returning data as a primitive non-scalar data structure to the client.
    Returning a ref cursor (aka a pointer to a cursor) means that you give the client direct access to the interface of that cursor program. Allowing the client to directly fetch and consume the output of that program. Enabling the client to deal with the standard SQL (cursor) interface.
    A significantly more performant and scalable method than to create a primitive result set cache in server memory for the output and then shipping that (as a non-standard data structure) to a client.
    A ref cursor interface can returns millions of rows and GBs of data. How many rows do you think this approach of yours will take? How many clients can call that same PL/SQL interface of yours at the same time, before the memory footprint of caching SQL data in the PGA for external clients exceeds free server memory?
    Do you realise what happens next? Swap daemons trashing badly consuming most of the CPU (even starving the kernel itself). If you're lucky, the server will crash quickly. If not, even console access to the server in attempt to fix mess will be something like typing one character every 60 seconds at the console.

  • Return array of varchar from oracle to java

    I am trying to return an array of varchar from database to java. However, when I print the values in java, it prints hexadecimal values like this.
    I am using oracle and jdk 1.4
    This happens only when the NLS character set of the database is WE8MSWIN1252 (default character set).
    It works fine on databases with UTF8 and US7ASCII character sets.
    Any leads to the reason behind this behaviour is greatly aprpeciated.
    Here's the code snippet...
    create or replace type SimpleArray
     as table of varchar2(30)
    create or replace function getSimpleArray return SimpleArray
     l_data simpleArray := simpleArray();
      for i in 1 .. 10 loop
          l_data(l_data.count) := 'entry ' || i;
        end loop;
        return l_data;
    public static void main(String[] args)
         try {
              String url = "jdbc:oracle:thin:@localhost:1521:db1252";
              Connection conn = DriverManager.getConnection(url, "ring", "ring");
              CallableStatement stmt = conn.prepareCall("{? = call "
                             + "getSimpleArray" + "}");
              Array rs = null;
              ResultSet rsltSet = null;
              stmt.registerOutParameter(1, Types.ARRAY, "SIMPLEARRAY");
              rs = stmt.getArray(1);
              String[] values = (String[]) rs.getArray();
              for (int i = 0; i < values.length; i++) {
              rsltSet = rs.getResultSet();
         } catch (Exception e) {
              System.err.println("Got an exception! ");

    Actually, check It looks like driver contains only the *.zip version. Make sure that the file exists in the directory pointed by the CLASSPATH. Use full path, do not use %ORACLE_HOME%.
    I have reproduced your problem without and I could not reproduce it with the file in the class path. Double-check how classpath is set in your environment. Maybe it is overriden by some configuration or batch file.
    -- Sergiusz

  • Pass an ArrayList of objects from C++ to JAVA using JNI

    I need to get the running Windows processes using C++ and have a Process struct in C++ having 2 fields: name and pid. I want to pass an ArrayList of Process from C++ to Java. I have found an example of how to pass an array of objects from C++ to Java, but I'd like to pass an ArrayList, and I was wondering if this is possible, before understanding that example and use an array.
    I don't have much experience with C++ and I don't even know if you have something like an ArrayList in C++, so I'm sorry if it doesn't make any sense what I'm talking about. Thank you.

    From C you can access and/or imnstantiate one of the
    java collections. In other words, your C code should
    simply populate java structures and a collection.I have read this is possible after I posted this, but didn't find an example yet. I began reading "Java Native Interface" book from Addison-Wesley today to get a better understanding of JNI.
    If you know where to find an example of doing this, I would appreciate it. Otherwise, I suppose I will find this in the above mentioned book quite soon... Thank you.

  • Oracle ADF Mobile getting array of objects from webservice

    i am trying to fetch a certain number of records using a webservice call and then storing in the SQLLite DB in the mobile.
    i understand i can create a data control using the webservice > then?
    my webservice returns an array of objects.
    how can i do that?

    It's fairly easy.
    What I have done is created a WebService Controller (plain java class) which calls the methods (from the WS) programmaticly.
    Example :
    public class WSController {
        private final String WSDataControllerName = "ThisIsTheNameOfMyWebserviceDataControl";
        private List pnames ,ptypes ,params;
        public WSController() {
        public List getAllActioncodesFromWS()
           //start - WS empty params
            pnames = new ArrayList();
            params = new ArrayList();
            ptypes = new ArrayList();
            //end - WS empty params
            List actionCodes = new ArrayList();
                GenericType result = (GenericType)AdfmfJavaUtilities.invokeDataControlMethod(WSDataControllerName, null, "findActioncodesView1",pnames, params, ptypes);
                    for (int i = 0; i < result.getAttributeCount(); i++)
                        GenericType row = (GenericType)result.getAttribute(i);
                        Actioncode wd = (Actioncode)GenericTypeBeanSerializationHelper.fromGenericType(Actioncode.class, row);
            catch (AdfInvocationException e)
            catch (Exception e)
         return actionCodes;
        }I also defined a Pojo named Actioncode :
    Note that the attribute names are completly the same as the VO from the web service.
    public class Actioncode {
        String Actioncode,Descript1;
        public Actioncode() {
        public Actioncode(String Actioncode, String Descript1) {
            this.Actioncode = Actioncode;
            this.Descript1 = Descript1;
        public void setActioncode(String Actioncode) {
            this.Actioncode = Actioncode;
        public String getActioncode() {
            return Actioncode;
        public void setDescript1(String Descript1) {
            this.Descript1 = Descript1;
        public String getDescript1() {
            return Descript1;
    }Since the WS method returns a GenericType, you can 'convert' that object to an POJO.
    Read more about it here :
    I know the blog post is about iterating over rows in an iterator, but it's just to illustrate how you can work with the GenericType

  • Deserialize an array of objects from a web service

    Hi, I'm calling a webservice method which returns an array of
    objects (let's
    say classes called MyClass).
    I now want to define a class in actionscript called MyClass
    which matches
    the properties of the class defined in the web service
    (written in .NET),
    call the webservice method, and then deserialize the result
    in actionscript
    into an array of type MyClass.
    The code I have so far is:
    var mylog:Log = new Log(Log.DEBUG);
    myLog.onLog = function(txt) {
    var ws:WebService = new WebService(wsc.WSDLURL);
    ws.onLoad = function(wsdl) {
    MyPendingCallObject =
    MyPendingCallObject.onResult = function(result)
    // HOW CAN I DESERIALIZE the result parameter into an Array
    MyClass ???
    MyPendingCallObject.onFault = function(fault)
    trace('FAULT! ' + fault.faultCode + "," +
    // If the WSDL fails to load the onFault event is fired.
    ws.onFault = function(fault) {

    I posted a similar problem some time ago : =1221565&enterthread=y
    Do you find any solution to your problem ?

  • Creating an arrays of objects from a class

    I was wondering does any one know how to create an array of objects from a class?
    I am trying to create an array of objects of a class.
    class name ---> Class objectArray[100] = new Class;
    I cant seem to make a single class but i need to figure out how to create an array of objects.
    I can make a normal class with Class object = new Class

    There are four lines of code in your for-loop that actually do something:
    for(index = 0; index < rooms.length; index++) {
    /*1*/  assignWidth.setWidth(Double.parseDouble(in.readLine()));
    /*2*/  rooms[index] = assignWidth;
    /*3*/  assignLength.setWidth(Double.parseDouble(in.readLine());
    /*4*/  rooms[index] = assignLength;
    }1.) Sets the width of an object, that has been instantiated outside the loop.
    2.) assigns that object to the current position in the array
    3.) Sets the width of a second object that has been instantiated outside the loop
    4.) assigns that other object to the current position in the array
    btw.: I bet you meant "assignLength.setLength(Double.parseDouble(in.readLine());" in line 3 ;)
    Since each position in an array can only hold one value, the first assignment (line 2) is overwritten by the second assignment (line 4)
    When I said "construct a new room-object and assign it to rooms[index]" I meant something like this:
    for(index = 0; index < rooms.length; index++) {
        Room aNewRoom = new Room();
        rooms[index] = aNewRoom;
    }1.) Constructs a new Object in every iteration of the for-loop. (btw: I don't know what kind of objects you're using, so this needs most likely modification!!)
    2.) set the width of the newly created object
    3.) set the length of the newly created object
    4.) assign the newly created object to the current position in the array
    btw. this would do the same:
    for(index = 0; index < rooms.length; index++) {
        rooms[index] = new Room();
    }but be sure you understand it. Your teacher most likely wants you to explain it ;)

  • How can I fill a table of objects from cursor with select * bulk collect???

    Hi All, I have a TYPE as OBJECT
    create or replace type dept2_o as object (
    deptno NUMBER(2),
    dname VARCHAR2(14),
    loc VARCHAR2(13));
    I can fill a table of objects from cursor with out select * bulk collect...., row by row
    TYPE dept2_t IS TABLE of dept2_o;
    dept_o_tab dept2_t:=dept2_t();
    i integer;
    for rec in (select * from dept) loop
    deptno => rec.deptno,
    dname => rec.dname,
    loc =>rec.loc
    end loop;
    for k IN 1..i loop
    dbms_output.put_line(dept_o_tab(k).deptno||' '||dept_o_tab(k).dname||' '||dept_o_tab(k).loc);
    end loop;
    But I can't fill a table of objects from cursor with select * bulk collect construction ...
    TYPE dept2_t IS TABLE of dept2_o;
    dept_o_tab dept2_t:=dept2_t();
    select * bulk collect into dept_o_tab from dept;
    ORA-06550: line 6, column 39;
    PL/SQL: ORA-00947: not enough values ....
    How can I fill a table of objects from cursor with select * bulk collect???

    create or replace type dept_ot as object (
    deptno NUMBER(2),
    dname VARCHAR2(14),
    loc VARCHAR2(13));
    create table dept
    (deptno number
    ,dname varchar2(14)
    ,loc varchar2(13)
    insert into dept values (10, 'x', 'xx');
    insert into dept values (20, 'y', 'yy');
    insert into dept values (30, 'z', 'zz');
    select dept_ot (deptno, dname, loc)
      from dept
    create type dept_nt is table of dept_ot
       l_depts dept_nt;
       select dept_ot (deptno, dname, loc)
         bulk collect
         into l_depts
         from dept
       for i in l_depts.first .. l_depts.last
          dbms_output.put_line (l_depts(i).deptno);
          dbms_output.put_line (l_depts(i).dname);
          dbms_output.put_line (l_depts(i).loc);    
       end loop;

  • Problem with return a ColdFusion query object from a Java class

    I need to return a ColdFusion query object from a Java class
    using a JDBC result set ( java.sql.ResultSet);
    I have tried to pass my JDBC result set in to the constructor
    of the coldfusion.sql.QueryTable class with this code:
    ColdFusion code
    <cfset pra = createObject("java","QueryUtil").init()>
    <cfset newQuery = CreateObject("java",
    <cfset newQuery.init( pra.getColdFusionQuery () ) >
    My java class execute a query to db and return QueryTable
    Java code (
    import coldfusion.sql.QueryTable; // (CFusion.jar for class
    import com.allaire.cfx //(cfx.jar for class Query used from
    public class QueryUtil
    public static coldfusion.sql.QueryTable
    getColdFusionQuery(java.sql.ResultSet rs)
    return new coldfusion.sql.QueryTable(rs);
    but when i run cfm page and coldfusion server tries to
    execute : "<cfset pra =
    createObject("java","QueryUtil").init()>" this error appears:
    Object Instantiation Exception.
    An exception occurred when instantiating a java object. The
    cause of this exception was that: coldfusion/sql/QueryTable.
    If i try to execute with Eclipse all it works.
    Also I have tried to return java.sql.ResultSet directly to
    coldfusion.sql.QueryTable.init () with failure.
    Do you know some other solution?

    i print all my code execute a query to db and return a querytable
    java class
    import java.util.*;
    import java.sql.*;
    import coldfusion.sql.*;
    public class Pratica {
    private HashMap my;
    private String URI,LOGIN,PWD,DRIVER;
    private Connection conn=null;
    //funzione init
    //riceve due strutture converite in hashmap
    // globals
    // dbprop
    public Pratica(HashMap globals,HashMap dbprop) {
    my = new HashMap();
    URI = "jdbc:sqlserver://it-bra-s0016;databaseName=nmobl";
    LOGIN = "usr_dev";
    PWD = "developer";
    DRIVER = "";
    // Carico il driver JDBC per la connessione con il database
    /* Connessione alla base di dati */
    if(conn!=null) System.out.println("Connection Successful!");
    } catch (ClassNotFoundException e) {
    // Could not find the database driver
    System.out.print("\ndriver non trovato "+e.getMessage());
    catch (SQLException e) {
    // Could not connect to the database
    System.out.print("\nConnessione fallita "+e.getMessage());
    //funzione search
    //riceve un hash map con i filtri di ricerca
    public QueryTable search(/*HashMap arg*/) {
    ResultSet rs=null;
    Statement stmt=null;
    QueryTable ret=null;
    String query="SELECT * FROM TAN100pratiche";
    stmt = conn.createStatement();// Creo lo Statement per
    l'esecuzione della query
    // while ( {
    // System.out.println(rs.getString("descrizione"));
    catch (Exception e) {
    try {
    ret = Pratica.RsToQueryTable(rs);
    } catch (SQLException e) {
    // ret=this.RsToQuery(rs);
    // this.close(); //chiude le connessioni,recordset e
    //retstruct CF vede HashMap come struct
    public HashMap retstruct(){
    //conversione resultset to querytable
    private static QueryTable RsToQueryTable(ResultSet rs)
    throws SQLException{
    return new QueryTable(rs);
    //chiura resultset statament e connessione
    private void close(){
    catch (Exception e) {
    coldfusion code
    <title>Test JDBC CFML Using CFScript</title>
    <cfset glb_map =
    <cfset dbprop_map =
    <cfset glb_map.init(glb)> <!---are passed from
    another page--->
    <cfset dbprop_map.init(glb["DBPROP"])>
    <cfset pra =
    <cfset ourQuery
    <h2>Error - info below</h2>
    <cfdump var="#cfcatch#"><cfabort>
    <h2>Success - statement dumped below</h2>
    <cfdump var="#ourQuery#">
    error at line <cfset pra =
    An exception occurred when instantiating a java object. The
    cause of this exception was that: coldfusion/sql/QueryTable.

  • How can I return my iPhone4 to OS6 from OS7?

    How can I return my iPhone4 to OS6 from OS7?

    Several people on this discussion board have bought old phones that had not yet been updated and sold their updated phones.

  • Reading an Array of Objects from a .bin file!

    Hey, at the moment I'm creating a program whereby I write a set of objects onto a bin file, in this case an array of objects with a String name/county, and int population/area.... I'm not trying to read it back from the bin file and encountering trouble! I've managed to get it working using plain objects, however I want to be able to read in arrays of objects. The file itself compiles, however during running I get this error
    at RecordFiles.CoastalRead.main(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at bluej.runtime.ExecServer$
    Here is the program itself,
    public class CoastalRead {
        public static void main(String[] args) {
            CoastalTowns towns[] = new CoastalTowns[50];
              towns[0] = new CoastalTowns();
              towns[1] = new CoastalTowns();
              towns[2] = new CoastalTowns();
              towns[3] = new CoastalTowns();
              towns[4] = new CoastalTowns();
              String name, county;
              int population, area;
            try {
                FileInputStream fileIn =
                        new FileInputStream("CoastalTownsBin.bin");
                ObjectInputStream in = new ObjectInputStream(fileIn);
                for (int i = 0; i < towns.length; i++){
                 towns[i] =(CoastalTowns) in.readObject();
                   System.out.println("Deserialized File...");
                       System.out.println("Name: " +;
              System.out.println("County: " + towns[i].county);
         System.out.println("Population: " + towns[i].population);
              System.out.println("Area: " + towns[i].area);
    } catch (IOException i) {}
    catch (ClassNotFoundException c) {}
    +I'd appreciate a fast reply!+ And if someone needs the writing class I've used, I can post it asap.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    CoastalTowns towns[] = new CoastalTowns[50];
    towns[0] = new CoastalTowns();
    towns[1] = new CoastalTowns();
    towns[2] = new CoastalTowns();
    towns[3] = new CoastalTowns();
    towns[4] = new CoastalTowns();Why create an array with a size of 50 and then only fill 5 elements?
    Why bother filling any elements at all when you are reading the objects from a file?
    What happens if there are less than 50 objects in your file?
    I will assume CoastalTowns holds info about a single town, so why is it pluralised? Do you have a class called Dog or Dogs, Chair or Chairs, Person or People?
    } catch (IOException i) {}
    catch (ClassNotFoundException c) {}DO NOT swallow exceptions. At the very least put in a call to printStackTrace so you know if/when an exception occurs.
    I'd appreciate a fast reply!I typed as fast as I could but unfortunately I'm still and hunt and peck guy.

  • Formatted .data file, reading in and creating an array of objects from data

    Hi there, I have written a text file with the following format;
    List of random personal data: length 100
    1 : Atg : Age 27 : Income 70000
    2 : Dho : Age 57 : Income 110000
    3 : Lid : Age 40 : Income 460000
    4 : Wgeecnce : Age 43 : Income 370000
    and so on.
    These three pieces of data, Name,Age and Income were all generated randomly to be stored in an array of objects of class Person.
    Now what I must do is , read in this very file and re-create the array of objects that they were initially written from.
    I'm totally lost on how to go about doing this, I have only been learning java for the last month so anyone that can lend me a hand, that would be superb!

    Looking at you other thread, you are able to create the code needed - so what's the problem?
    Here's an (not the only) approach:
    Create an array of the necessary length to hold the 3 variables, or, if you don't know the length of the file, create a class to contain the data. Then create an ArrayList to hold an instance of the class..
    Use the Scanner class to read and parse the file contents into the appropriate variables.
    Add each variable to either the array, or to an instance of the class and add that instance to the arraylist.

  • Extracting Array of objects from web service

    After a couple days of head banging I now have a webservice
    call executing and I am trying to extract / create a class from the
    If the xml returned from the web service is:
    <person name="Mike" />
    <person name="Dave" />
    and the class is:
    class Person
    public var Name:String;
    The result event is:
    private function doResults(result:ResultEvent):void
    // how do I create an array of Person objects from result, I
    would also like to know how to create a typed array something like
    class PersonList if possible. I just need the raw how to loop the
    result and set the values on the class

    Well I wound up with just trial and error until I got it
    working, Im sure this will be improved as I go, but it's enough to
    press on with the app for now, this code is in the result function
    and result is the ResultEvent wich appears to be an array of
    generic objects representing the objects returned by the service.
    This in no way uses FDS and is talking to a simple dotnet /
    web service.
    // here app is a singleton class for app level data it is
    bindable and is used to update the view which in this example is
    bound to a public var MyObjects which in this case is an
    ArrayCollection, I unbox to MyObject in a custom view control
    for (var s:String in result.result)
    m = new MyObject();
    m.ID = result.result[s].ID;
    m.Name = result.result[s].Name;
    m.Type = result.result[s].Type;
    It also appears that you should create the WebService one
    time, and store refrences to the methods during app startup, the
    methods are called Operations and it appears you set the result and
    fault events then call send on the operation to get the data.
    // store this in a singleton app class
    var ws:WebService = new WebService();
    ws.wsdl = "";
    // this is the operation which is also stored in the
    singleton app class
    var op:AbstractOperation = ws.getOperation("GetModules");
    // elsewere in the app we get the operation refrence setup
    result and fault and call send, then copy the generic object into
    our cutom classes using the first chunk of code above
    I thought I would post this as I could find no such example
    in the offline or online docs, If anyone has a better way or see's
    a problem please post.
    I hope helps others with non FDS service calls and I look
    forward to hearing comments.

  • How can servlet return data as download file from browser ? !!! URGENT !!!

    My servlet query data from database and would like to return the data as text file.
    How can I return data to the browser as user click a file to download ?
    How can I set the file name ? (default name is the servlet name that I don't want it to be)
    Which content type should I return to browser to prevent browser to display data immediately but save instead ?
    Thank you very much !

    I am having the same issue. Did you ever discover a way to change the "file name" in the browser. I've tried changing numerous HTTP header fields, to no avail.

Maybe you are looking for

  • PDF file to be attached in mail .Showing error in opening the Document .

    Hi ABAP Gurus , Good Morning ! I converted a smartform to PDF and sended to function SO_NEW_DOCUMENT_ATT_SEND_API1 to send a mail external... So, when I tried to open the file attachment, I can't open this file. and I watch a message : 'There was a e

  • Resolution of image in monitor window

    How can I get the image in the monitor window to be as sharp as the image in the preview window in Premier Elements 10?

  • Min runtime in Campaign Planning

    Hi, Can anyone tell me how to setup minimum runtime in campaign planning in PP/DS. The campaigns are defined by different colors (setup group) of the products. I am not sure how to ensure minimum runtime for a campaign i.e. a specific color to run at

  • How to find the concurrent user licenses usuage

    Hi, Can you someone tell me how to find the concurrent user licenses usage. if i go to CM C -> Settings -> View Global System Metrics then it is showing strange number in the area of peak licenses used since deployment  (more than 5K), Is there is an

  • Word not working properly after W7 upgrade

    Word is acting exactly like it did on my old machine before I purchased my new PC three months ago....I use Office 2003.....the Thesaurus won't work, when I click Page Setup it says Not Responding for some time before it finally pops up the Page Setu