-
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.? :(y):
-
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.
-
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 .
-
Re: methods available
So two Strings you concatenate together.
Actually, two StringBuilders, hopefully.
-
Re: methods available
I will check out about StringBuilders i am not sure about that
-
Re: methods available
If yo have this code (as an example:
Code:
String myString = "";
for (String aString : myListOfStrings) {
myString += aString;
}
Then the compiler will create a StringBuilder each time round that loop in order to do the '+='.
WHereas:
Code:
StringBuilder myString = new StringBuilder();
for (String aString : myListOfStrings) {
myString.append(aString);
}
uses the single StringBuilder you created.