Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

corba idl sql resultset java.util.vector

 
maik maik
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
maik maik
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic