Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
    Bookmark Topic Watch Topic
  • New Topic

JDBC return null when called from a servlet

 
ankur tyagi
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Report post to moderator
i have a class file that does all the jdbc stuff and return the values from the database to the servlet..
but the problem is when i call the class from the servlet , the resultset is null
but when i call the same class from other class' main: the values are returning jsut fine..
i even stuffed all the functions in the servlet class but still no solution
the oracle is running on default 8080 port and tomcat is running on 8081.
here is the servlet with everything in it

can any one help its important for me.
i am stuck on it....
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Report post to moderator

oracle is running on default 8080

That's not the default port for Oracle.

Why are you using the JDBC-ODBC bridge to connect to Oracle? Would it not be easier and better to use the thin driver?

When you say "the resutls set is null" do you mean it is empty or are you getting a NullPointerException?

One other thing - you should close connections after you've finished with them otherwsie you waste database resources.
 
ankur tyagi
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Report post to moderator
i am getting null pointer exception so the catch is running ..
my oracle is running on 8080 because it clashed with Tomcat so i changed the port for tomcat from 8080 to 8081..
i will worry about resources after its running ..
can you explain the thin drivers..
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Report post to moderator
*WHERE* do you get a NullPointerException?
 
ankur tyagi
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Report post to moderator
when i am calling the rs.next() function...
on line 26 of the code
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4588
302
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Report post to moderator
Make rset a local variable of View(String qry) method.
 
ankur tyagi
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Report post to moderator
still not working man!!!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
ankur tyagi wrote:still not working man!!!


Please calm down.
It's not our job to fix your code.
Be grateful that people are trying to help you for free.

 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Duplicate of:
http://www.coderanch.com/t/493572/Servlets/java/Null-Pointer-Exception

I've also noticed that you've already asked this in another forum.
I answered it there.
If you have further questions, please continue in the original thread.
 
    Bookmark Topic Watch Topic
  • New Topic