dcsimg
equivalent of a collection...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   David_Jacobson
Posted On:   Wednesday, May 26, 2004 11:59 AM

I am working with an existing set of code that uses Java Server Pages to display content and Java classes on the backend. The existing code Java classes query a database and return result sets in Collection objects. We are talking about using Axis to separate the backend from the front-end and then create a set of operations that the front-end can use to build the web pages. We also do not want to force the front-end to use Java. So my question is what datatype should we use to return a result set from query to the database? Obviously if we are only querying one column we can just use the datatype of the column; e.g., String, Integer, etc. But what if the query returns four columns; e.g., an integer and three strings? And we don't just get    More>>

I am working with an existing set of code that uses Java Server Pages to display content and Java classes on the backend. The existing code Java classes query a database and return result sets in Collection objects.



We are talking about using Axis to separate the backend from the front-end and then create a set of operations that the front-end can use to build the web pages. We also do not want to force the front-end to use Java.



So my question is what datatype should we use to return a result set from query to the database? Obviously if we are only querying one column we can just use the datatype of the column; e.g., String, Integer, etc. But what if the query returns four columns; e.g., an integer and three strings? And we don't just get one row back but we get 5 rows or 50 rows back. What datatype should I use to store this information to pass to the front-end?



I think this is a basic question but I am a Java novice. Thanks in advance for the help.

   <<Less

Re: equivalent of a collection...

Posted By:   Sean_Owen  
Posted On:   Wednesday, May 26, 2004 03:22 PM

There are sort of two questions floating around here...



First, if you are writing some generic utility class that will return a result set from a query, consider returning a List of Maps. Each Map maps column names to values. This is not necessarily the most efficient thing to do, but it simple and straightforward.



You can try to expose such a method as a web service, using Axis, though I think it will be some work to get the desired effect. It's a complex topic but basically that "List of Maps" data type is going to get lost in the translation... what would the WSDL look like, and what would a .NET client do with that?



If you are exposing a web service, it should really expose more concrete data types. For example you might return some particular "WidgetInfo" object with an Integer property, and 3 String properties, from some web service. That's more the sort of thing that web services / Axis are for... these "translate" much better.

About | Sitemap | Contact