• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

DB connection and a null pointer exception

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey everyone,

If you guys don't mind reading some code i need some suggestions as to why i am receiving a NullPointer Exception.
Tomcat says it encountered an internal error.

Ive narrowed the problem down to line 41, in the DataAccess class. I don't understand why this is giving me a problem because ive use this code before in a java gui and no problems..

This is my first shot at servlets so some advice would help me a long way.

Thanks

Servlet


DataAccess Class

 
Sheriff
Posts: 27451
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Line 41? Then the error is simply that the variable "statement" is null. You haven't ever set it to anything other than null.

The only place you might set it is Line 10. But if Line 7 throws an exception then that line would never be executed. That's my guess about what really happened.

And it makes no different that this code happens to be in a servlet, or called from a servlet. It's just Java programming so let's move the thread there.
 
Joe Deluca
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ya you were right, i forgot to put in the J Connector
thanks
 
Story like this gets better after being told a few times. Or maybe it's just a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic