• 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

Getting SQLException and NullPointerException while trying to access DB

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Currently i am using ecllipse galileo 3.5.2 , Java-Open-JDK-1.6, Tomcat 6.0.29 as app server,Oracle 10g XE DB in Ubuntu 10.10. I am running a sample servlet to list the employee details from the DB.I have set the configuration parameters in Deployment Descriptor for the connection str,user id and password to access the DB.


I am accessing these parameters through the following code in the servlet .



But i am getting the following Exceptions in the Console on executing the Servlet -



I tried checking out the Marked errors in Markers window in eclipse and tried again . Then also the same above exceptions are coming but the output is getting printed to the browser.



-> And also another point that i wanted to know is -> How to get sample data for tables like EMPLOYEE in Oracle 10G XE as there is no sample data present for it when i searched for data in the DB?

Any solution to the query will be utmost helpful
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you do a println do make sure the "connStr" is being read in from the context parameter?
 
adil ibnashraf
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I printed the values . Getting null null null on giving prints


 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That means you have a Servlet question and not a JDBC problem. Moving to the servlets forum.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Isn't the ServletContext where one gets the initialization parameters?

So you would do:
 
adil ibnashraf
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry , being a newbie i have not got much idea what to post where, Anyways - I have resolved that issue by giving the url,user-id,password in <init-param> section of the servlet in web.xml but still need to know why setting the same values in context-param section dint work . Will check that out in servlet forum .
 
adil ibnashraf
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok will check by giving ServletContext in init() function
 
adil ibnashraf
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yippie !!! Initializing the connection str,user id and passwd with servlet context variables has resolved the issue.



Now the values are clearly coming without exception

 
Bring out your dead! Or a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic