aspose file tools*
The moose likes Distributed Java and the fly likes corba idl sql resultset java.util.vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "corba idl sql resultset java.util.vector" Watch "corba idl sql resultset java.util.vector" New topic
Author

corba idl sql resultset java.util.vector

maik maik
Greenhorn

Joined: Jul 03, 2004
Posts: 5
Hi,

I have a question concerning sql and corba.
I have written a Corba-Server which is quering a database. Now I want the ResultSet beeing sent to my Corba-Client. As I heard(better read) it is impossible to ship a resultset. A way is to copy the resultset in a java.util.vector (which I have done). But what do I have to do now? Can somebody help me please? For example how must the IDL look like to cope with my vector?
Any help will be deeply appreciate, because I am getting very desperate.

Thank you a lot
Maik from Germany


[...]

ResultSet rs = stmt.executeQuery(sql);

Vector list = new Vector();
while (rs.next())
{
list.addElement(rs);
}
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Take a look at these articles from DeveloperWorks on OMG IDL and IDL to Java mapping... both of these links are to the "Sequences and Arrays" sections in each of the documents.


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
maik maik
Greenhorn

Joined: Jul 03, 2004
Posts: 5
Hi Nathan,

I looked at the links that you advised to me, but I couldnt manage to create a suitable IDL for my method.

Could you or somebody else please write me an suitable IDL?

That would be very kind of you.
Thank you a lot.
Maik


static Vector output (java.sql.ResultSet result, Vector newvec, int col)throws SQLException
{


while (ersult.next())
{
Vector row = new Vector(); // create row vector
for (int i=1; i<= col; ++i)
{
//convert to String
System.out.print(result.getString(i) + "\t");
row.add(result.getString(i));
}
System.out.println("");


newvec.add(row);
}


return result;
}
maik maik
Greenhorn

Joined: Jul 03, 2004
Posts: 5
I am sorry but there were some tipping mistakes in my code which I have cleaned now.

static Vector output (java.sql.ResultSet result, Vector newvec, int col)throws SQLException
{


while (result.next())
{
Vector row = new Vector(); // create row vector
for (int i=1; i<= col; ++i)
{
//convert to String
System.out.print(result.getString(i) + "\t");
row.add(result.getString(i));
}
System.out.println("");


newvec.add(row);
}


return newvec;
}
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Sorry, I didn't provide enough information in my last post... I was forwarding you to the "Arrays and Sequences" section because I don't think you'd be able to send a "java.util.Vector" object across CORBA (I'm not a big CORBA expert, if anyone who knows better can tell how to do this, please do!) but you could easyily create a struct in the IDL for the type of data you are getting out of the ResultSet and return an array or sequence of that type.

There's a short example at JavaWorld comparing CORBA and RMI where they use a Vector in the RMI example and a sequence of ResultSet objects (*not* java.sql.ResultSet... they just called their data objects that in the example) for the CORBA example.
maik maik
Greenhorn

Joined: Jul 03, 2004
Posts: 5
Hi Nathan,

Thanks for your help!
I finally could send an array form server to client, and could at least solve my particular probleme!

An IDL for sending arrays or sequences must look like this:

//DB.idl

module DBApp
{

//defines a sequence with 8 elements
typedef sequence<string,8> array_of_String;

//or alternatively you can define an array
typedef string list[8];

interface DB
{
array_of_String Connection();
list Connection();
};

};

I hope this will help everyone who starts learning corba like me. If there is somebody out there in this wide world who knows how you can send ResultSet Objects, please post an example, no matter how old my own posting will be.

Greetings from Maik
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: corba idl sql resultset java.util.vector
 
Similar Threads
Passed ResultSet is not working
Confusion with RMI-IIOP and Java-IDL. Need your help
Problems with Vector and JNDI
Use of NIO
Help please