Results 1 to 6 of 6
Thread: methods available
- 03-05-2012, 06:18 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 60
- Rep Power
- 0
methods available
Is there any method available in REsultSet class that will enter the entire column as a array of string.
For example if the resultset obtained contains 2 columns and 5 rows is there any method available to get only the values available in the first column. That is it need to return the 5 values of first column.?
- 03-06-2012, 09:32 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: methods available
No.
ResultSets are simply a cursor which points at a row in the result.
You'd either have to change your query to return the data in that format, or iterate over the results and concatenate the data in Java.
If you only want the values form the first column then I would question why you have a query that returns data from column 2 as well.Please do not ask for code as refusal often offends.
- 03-06-2012, 02:19 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 60
- Rep Power
- 0
Re: methods available
I wanted to display it like that to the user.. All the column one first and then two . I did that by moving the cursor of the resultset and then storing it in a String .
- 03-06-2012, 02:31 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: methods available
So two Strings you concatenate together.
Actually, two StringBuilders, hopefully.Please do not ask for code as refusal often offends.
- 03-06-2012, 02:44 PM #5
Member
- Join Date
- Feb 2012
- Posts
- 60
- Rep Power
- 0
Re: methods available
I will check out about StringBuilders i am not sure about that
- 03-06-2012, 02:53 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: methods available
If yo have this code (as an example:
Then the compiler will create a StringBuilder each time round that loop in order to do the '+='.Java Code:String myString = ""; for (String aString : myListOfStrings) { myString += aString; }
WHereas:
uses the single StringBuilder you created.Java Code:StringBuilder myString = new StringBuilder(); for (String aString : myListOfStrings) { myString.append(aString); }Please do not ask for code as refusal often offends.
Similar Threads
-
Trouble with static methods and boolean equals() methods with classes
By dreamingofgreen in forum New To JavaReplies: 8Last Post: 04-16-2012, 11:00 PM -
Java Noob, trying to call methods from another methods
By gabrielpr12 in forum New To JavaReplies: 8Last Post: 11-17-2011, 09:07 PM -
difference between static methods and instantce methods?
By venkatch in forum New To JavaReplies: 1Last Post: 10-23-2011, 12:37 PM -
Incorporating If-Else into Methods + Private Helper Methods?
By 5minutes in forum New To JavaReplies: 1Last Post: 10-05-2011, 12:15 AM -
How to get methods to see variables in other methods
By ejs7597 in forum New To JavaReplies: 4Last Post: 04-03-2009, 06:36 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks