This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes NullPointer Exception using JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "NullPointer Exception using JDBC" Watch "NullPointer Exception using JDBC" New topic
Author

NullPointer Exception using JDBC

Paras Ahuja
Ranch Hand

Joined: May 22, 2012
Posts: 62
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

Joined: May 03, 2008
Posts: 4523
    
    5

Break that up and add a debug sysout.


luck, db
There are no new questions, but there may be new answers.
Paras Ahuja
Ranch Hand

Joined: May 22, 2012
Posts: 62
Thanks, but its still not working....
Do you know why the error is being generated?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10175
    
    8

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.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Probably rs.getString(1) returns null.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NullPointer Exception using JDBC
 
Similar Threads
having problems getting my Runnable Interface working
SWING GUI ADVICE,PLEASE
SWING GUI ADVICE,PLEASE
how to fix the JLabel Text value in Swings
ATM machine