Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

NullPointerException, but it should be working

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have already got 1 web app running, I have just tried to copy exactly what I did with the first one but this one doesn't seem to be working. Been comparing them in every detail but can't see where the problem lies. Hopeing a fresh pair of eyes can see the problem. Cheers.

Error:
java.lang.NullPointerException
income.addleadnew.doGet(addleadnew.java:96)
income.addleadnew.doPost(addleadnew.java:163)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

My Code:


Web.xml


CKS
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,

most probably your connection object (conn) is null. Check if you are able to connect to the DB server with the same credentials and url in stand alone program.
 
Michael Cropper
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I have done what you have just asked.

I just installed netbeans, then on the tab in the left under Services there was an expandable file list with one of them being 'databases', then 'drivers'. I saw the JDBC Driver so I right clicked on that and set up all the details the same as I have in this servlet. This mysql db then showed up in the list with all the tables and data in. So I can get into it that way.

I can also still access it via the command line.

What could the solution to this problem be?

Michael
 
Michael Cropper
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ALL SORTED NOW

I needed to put the JDBC Driver .jar file inside WEB-INF/lib . I checked out the tomcat logs which mentioned the 'com.mysql.jdbc.Driver' could not be found so just started putting that file everywhere until tomcat could find it :-D

Cheers for all the help everyone!

CKS
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic