• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointer Exception using JDBC

 
Paras Ahuja
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
i am encountring a very strange problem. I have two textfields tf[0] and tf[1] on a JFrame. Now, when anyone clicks on Ok button(again a component in my frame), the texts of the textfields are compared to values in an excel sheet. If the text entered in textfields already exist in the excel sheet, it generates error. Here is part of my code:


Now, the problem is: whenever i enter a value (already existing in the excel) in tf[1] ie. for Access IP, the code runs perfectly and it displays the error as its supposed to.
But when i enter a value (which is new and doesn't exist in excel) it generates following error:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Excel shows the error occurs at the { after the following line:


Please help....

 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Break that up and add a debug sysout.
 
Paras Ahuja
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, but its still not working....
Do you know why the error is being generated?
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paras Ahuja wrote:Thanks, but its still not working....
Do you know why the error is being generated?

ItDoesntWorkIsUseless
Copy paste the full stack trace. The error indicates some variable is null.
 
Rob Spoor
Sheriff
Pie
Posts: 20493
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably rs.getString(1) returns null.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic