Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.lang.NullPointerException at doPost

 
Shantanu Kulkarni
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I recently started java programming, so yes, i'm a greenhorn.
I'm getting java.lang.NullPointerException at doPost() method in my serlvet. Code is posted below. can anyone help me please?
Console says, it is at> pst = con.prepareStatement("SELECT EMPNAME, EMPID FROM EMPLOYEES WHERE EMPNAME= ? AND EMPID= ?"); (line#65 in the below code.)

I'm using oracle 10g. username, password, host string, url etc are correct. i can see the values in table.



LoginServlet.java


Console:
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh so many problems....

You have defined and instance variable con in line 20

Then another Connection con in the init method - so naturally the instance con remains null

You need to realize that programming for servlets requires a mental switch from programming for desktop applications.

Bill
 
Shantanu Kulkarni
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I did not realize i declared 'con' twice
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic