aspose file tools*
The moose likes JDBC and the fly likes Returning just a STRING  from....... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Returning just a STRING  from......." Watch "Returning just a STRING  from......." New topic
Author

Returning just a STRING from.......

Gabriel Fox
Ranch Hand

Joined: Oct 17, 2001
Posts: 170
Hi Guys. If i run a simple query that returns
5 records each with a column as follows :
select * from tableName
..... returns:
row1 = aaa
row2 = bbb
row3 = ccc
row4 = ddd
row5 = eee
Question : How do i get just a String from the
resultset .Which means concatenating all the
records on the database and returning just one String object from my resultset.
Hence desired result:
String x =aaa + bbb + ccc + ddd + eee ;
All codes and references will be appreciated
NOTE : my actual logic is returning 1000s of records with say 5 columns each and i need all as an object from a query on an Oracle
back end.I donot have a clue how to go about this.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

I can't see how you will accomplish this on the database side, but you can code this:

I know it isn't what you wanted (on the backend) but it will do what you want.
Jamie
[ March 21, 2002: Message edited by: Jamie Robertson ]
Kareem Qureshi
Ranch Hand

Joined: Mar 14, 2002
Posts: 102
Hi,
You can do one more thing, in your sql statement concatenate all the columns so that you get one column and then rs.getString(1) will give you string of all the five columns
snippet: select col1 || col2 || col3 || col4 || col5 somename from table;
and now as Jamie has given the code append the each row in the result to a stringbuffer object.
Hope this helps
Kareem
Kareem Qureshi
Ranch Hand

Joined: Mar 14, 2002
Posts: 102
Hi,
I am sorry i misread your question. You are talking about the rows.
Kareem
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Returning just a STRING from.......