Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting SQLException and NullPointerException while trying to access DB

 
adil ibnashraf
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34372
345
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I printed the values . Getting null null null on giving prints


 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34372
345
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
Marshal
Posts: 34372
345
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic