File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes NullPointerException on INSERT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "NullPointerException on INSERT" Watch "NullPointerException on INSERT" New topic

NullPointerException on INSERT

Bob Backlund
Ranch Hand

Joined: Jun 05, 2003
Posts: 51
Hi I'm pretty new to the whole SQL/Java thing, I'm trying to right a simple JSP/Servlet site. (well I thought it'd be simple)
Simply the user can enter some data into a set of fields on a JSP, this is then passed through a Sevler to another JSP. The Servlet is getting the data from the fields (I have System.out to show the data values) but the insert is failing with a java.lang.NullPointerException expection, even though all fields have a value in them and could accept a NULL value anyway.
The only thing I can think of, is i have a 'ID' field which is currently being left blank, however like i said it can have a NULL value so I don't think this should be a problem.

Nagendra Prasad
Ranch Hand

Joined: Jul 11, 2002
Posts: 219
Are you sure it is the insert that is throwing the NullPointerException? Are you sure it is not somewhere else in the code?
Best would be to inspect the stack trace? or post it here... I can take a look and offer my 2 pence worth of advice.

Best Regards,<br />Nagendra Prasad.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33130

Are you by any chance trying to do this?

This is a commonly used invalid way of inserting null.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: NullPointerException on INSERT
It's not a secret anymore!