File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes jdbc and servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "jdbc and servlets" Watch "jdbc and servlets" New topic

jdbc and servlets

padmshree Patil
Ranch Hand

Joined: Dec 18, 2000
Posts: 54
I am using servlet to insert values in Result database.It's working fine.But when I retrive data .It only select one record and then raise exception as No data found
code is as below..
rs =st.executeQuery("select mark from Result");
out.println("after executing query " + "

/** after this statement it raises exception and comes out of while and print marks obtained ststement **/

count = count+ rs.getInt("Mark");
out.println("after adding marks to count");
out.println("count " + count + "
out.println("Marks from database ......" + rs.getInt("Mark") + "
}catch(SQLException e)

out.println("marks obtained : " + count);
Rusult dabase has total 5 records.Why is it fetching only one record?
Bhupinder Dhillon
Ranch Hand

Joined: Oct 12, 2000
Posts: 124
You should get the value once only. If you repeatedly try getting the same value from the same row then it throws exception.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
I didn't notice that. Also, the "Mark" must be in the same case as the "select" statement.

Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
padmshree Patil
Try reviewing the demo jdbc examples that come with the jdk.
I think if you review some code examples.
Most of you How-To jdbc question can be resolved...

Multi Platform Database Developer & DBA on E.S.T.
I agree. Here's the link:
subject: jdbc and servlets
It's not a secret anymore!