• Post Reply Bookmark Topic Watch Topic
  • New Topic

regarding Retrival of multiple values from db using result set

dilip satyaraghava
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Doing this i am getting a NULL POINTER EXCEPTION.
How can i get rid of this problem??
Martin Vajsar
Posts: 3752
Chrome Netbeans IDE Oracle
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the exception actually occurs in the code snippet you've shown, then either i is null, rs is null, funame is null or fupwd is null.

Post full stack trace (obtained by catching the exception and invoking its printStackTrace method) and full source code of the class where the exception occurs, so that we can match line numbers from the stack trace with your code. We'll be able to provide better help then. Click TellTheDetails to see the why and how.

Foot note: there are few other possible improvements to your code:

1) Loading a list of users and their passwords from the database is probably a bad idea. User authorization should be done by other means, ie. selecting just the row from the database that matches given username and password; if a record is returned, the password matches, if no record comes back, the user or password is invalid. Moreover, passwords should be stored hashed in the database, but maybe you'Re already doing that.

2) Using lists instead of arrays is probably easier, less error prone and often more efficient.

3) Instead of two separate arrays, one array holding instances of class (say) User with attributes userName and password would probably be a better (and less error prone) design.
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!