aspose file tools*
The moose likes JDBC and the fly likes jdbc and servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "jdbc and servlets" Watch "jdbc and servlets" New topic
Author

jdbc and servlets

padmshree Patil
Ranch Hand

Joined: Dec 18, 2000
Posts: 54
Hi,
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..
--------------------------------------------
try
{
rs =st.executeQuery("select mark from Result");
out.println("after executing query " + "
");
while(rs.next())
{

out.println(rs.getInt("Mark"));
/** 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(e.getMessage());
}
}

out.println("marks obtained : " + count);
--------------------------------------------------
Rusult dabase has total 5 records.Why is it fetching only one record?
--
Padmashree
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...
Monty


Multi Platform Database Developer & DBA on E.S.T.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jdbc and servlets
 
Similar Threads
Servet and Jdbc
Accessing data in ResultSet object
How to get no of Rows ?
ResultSet and count urgent please help
Is there any one who can help me...Please?