while (rs.next())
                System.out.println("Name: "+rs.getString(1)+"\n");
                System.out.println("Age: "+rs.getInt(2)+"\n");
                System.out.println("Address: "+rs.getString(3)+"\n");

I just don't understand what is the meaning og getString(1)

Member Avatar

Hi NajwaMY,

assuming your resultset (e.g. created by rs = stmd.executeQuery( "select Name, Age, Adress from yourTable")) would be:

Name   Age   Adress
----   ---   ------
James  15    Marcus Ave
Ann    16    Lake Success
Dani   17    NY 11042

rs.getString(1) returns the value of the first column (here "Name") of the current row. If you follow JamesCherrill's link, you will see there are two (overloaded) member functions getString (int) and getString(String). getString(int) returns the value by means of a column index (1, 2, up to column count), whereas getString(Sting) returns the column value through an associative way, e.g. getString("Name"). Current row is selected by rs.next().

I hope, I could help you.

Ah yes, almost forgotten, I do not anymore care of getting down voted because above is out of harmony with somebody's perception neither when asking a plain question (check my down votes!).

yours 1StDan