File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes null pointer exceptiion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "null pointer exceptiion" Watch "null pointer exceptiion" New topic
Author

null pointer exceptiion

jyotsana dang
Ranch Hand

Joined: Sep 26, 2003
Posts: 135
what is null pointer exception ? And how do we rectify it? I have written a JSP code for inserting values to a database. But Iam getting a null pointer exception for the same..
Natraj Gudla
Ranch Hand

Joined: Feb 09, 2003
Posts: 34
When ever a "null" is used when an object is required, a NullPointerException is thrown.
To avoid this we need to be careful while assiging object references and creating structures.Explicit check on the null references before they are used can avoid such exceptions.
Natraj Gudla
Ranch Hand

Joined: Feb 09, 2003
Posts: 34
sorry..a correction...it is a null not a string "null".
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 613
Jyotsana ,
NullPointerEception is thrown whenever you use dot(.) with and variable which is object and contains null value.
say you have String s=null;
and you say s.substring(); this is same as null.substring(); which throws an nullpointer exception.
In your case I guess you are getting null pointer exception during creating connection.
just chek if your connection object is not null before createing statment like..stmt=con.createStatement();
Cheers
Praful


All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Not a JSP concept. Moving this to the Java in General(beginner) forum.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: null pointer exceptiion
 
Similar Threads
problem in running exec() from servlet
explain me this code
double Type of Value in JTable
SCJP Brainteaser (2)
problem to display session attribute