I am using the following code, but its not working correctly
This does not describe the problem.
As I would say, you have only one User object in your list. This is because you need to create a new User () object every time you read a new line from a ResultSet:
try {
while (rs.next()) {
User user = new User();
user.setId(rs.getInt("id"));
user.setUsername(rs.getString("username"));
user.setFname(rs.getString("fname"));
user.setLname(rs.getString("lname"));
user.setUsertype(rs.getInt("usertype"));
user.setPasswd(rs.getString("passwd"));
user.setEmail(rs.getString("email"));
userList.add(user);
}
source
share