wood burning stoves 2.0*
The moose likes JDBC and the fly likes JDBC return null when called from a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

JDBC return null when called from a servlet

ankur tyagi
Ranch Hand

Joined: Apr 01, 2009
Posts: 49
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

Joined: Apr 14, 2004
Posts: 10336


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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
ankur tyagi
Ranch Hand

Joined: Apr 01, 2009
Posts: 49
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

Joined: Sep 29, 2008
Posts: 12617

*WHERE* do you get a NullPointerException?
ankur tyagi
Ranch Hand

Joined: Apr 01, 2009
Posts: 49
when i am calling the rs.next() function...
on line 26 of the code
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3023
    
  35

Make rset a local variable of View(String qry) method.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
ankur tyagi
Ranch Hand

Joined: Apr 01, 2009
Posts: 49
still not working man!!!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JDBC return null when called from a servlet
 
Similar Threads
Null Pointer Exception
Null pointer exception sometimes
Servlets And Database Connection
help regarding jdbc
not able to establish connection for jdbcodbcdriver