jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes resultset value in vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "resultset value in vector" Watch "resultset value in vector" New topic

resultset value in vector

Nitin Belaram
Ranch Hand

Joined: Mar 24, 2009
Posts: 67
i am using vector to get result set value, but i am getting all 1st column value ,i am not getting all rows and column


public static List<New_USER> list() throws DaoException, ClassNotFoundException
System.out.println("inside list");
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
Vector listOfemp = new Vector();
// List<New_USER> users = new ArrayList<New_USER>();

connection = connectsql.getConnection();
preparedStatement = connection.prepareStatement(SQL_FIND_BY_ID);
resultSet = preparedStatement.executeQuery();
System.out.println(resultSet + "list Method");
while (resultSet.next()) {

// users.add( mapNew_USER(resultSet));

System.out.println("After New_USER");
System.out.println(listOfemp +"AN");
catch (SQLException e) {
throw new DaoException(e);

return listOfemp;

please suggest how to get all value in result set
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

you can use resultSet.getString or Int(2)..(3) and so on till the no of columns requested in SELECT query.
resultSet.next() will fetch you all rows matching the Criteria in the SELECT query.

BTW you can run the generated query in the DB and check the output.
Pravin Shirke
Ranch Hand

Joined: Apr 05, 2008
Posts: 150

Hi Nitin,
what you can do is:
Instead of this

insert this:

get all the columns like this or instead put a for loop inside a while loop

Hope this Helps!!! >

[Vipassana] - It is seeing the reality as it is, And not as you want it to be.!!!
Nishan Patel
Ranch Hand

Joined: Sep 07, 2008
Posts: 689


when you write

when you fire your query it gives result and it gives to your resultSet.

so you use resultSet.next iterate all row get by your query.

this gives you only first column of your resultSet.

you have to add all your column to your vector.

Thanks, Nishan Patel
SCJP 1.5, SCWCD 1.5, OCPJWSD Java Developer,My Blog
I agree. Here's the link: http://aspose.com/file-tools
subject: resultset value in vector
It's not a secret anymore!