• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.lang.NullPointerException at doPost

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. I did not realize i declared 'con' twice
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic