File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Databases
»
JDBC
Author
Exhausted Resultset
Amit kumar
Greenhorn
Joined: May 09, 2003
Posts: 16
posted
Aug 26, 2007 09:03:00
0
Where i am going wrong???
public static void main(String[] args) throws ClassNotFoundException, SQLException { // TODO Auto-generated method stub Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "123"); Statement stat = con.createStatement(); ResultSet rs; rs = stat.executeQuery("select * from Student"); while(rs.next()) { System.out.println("Student ID:: " + rs.getString("stdId")); System.out.println("Student::--:: "+"First Name:: "+ rs.getString("firstName")+" Last Name :: "+ rs.getString("lastName") ); } rs.close(); rs2= stat.executeQuery("select * from Student where firstname='Amit'"); while(rs2.next()) { System.out.println(rs2.getString("FirstName")+" " + rs2.getString("LastName")+" "+ "his id is "+ rs.getString("stdId")); }
this exception i am getting
Exception in thread "main" java.sql.SQLException: Exhausted Resultset at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:190) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:286) at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:536) at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1515) at com.jdbc.JdbcExample1.main(JdbcExample1.java:45)
tell to guide
David O'Meara
Rancher
Joined: Mar 06, 2001
Posts: 13459
I like...
posted
Aug 26, 2007 09:19:00
0
while(rs2.next()) { System.out.println(rs2.getString("FirstName")+" " + rs2.getString("LastName")+" "+ "his id is "+ rs.getString("stdId")); }
copy and paste error: check the variable for the result set used in each getString call above.
Dave
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: Exhausted Resultset
Similar Threads
Invalid Column Name in getString()--query worked
How To Solve : java.sql.SQLException: Exhausted Resultset
ResultSet.updateString() , updateInt() are not updating values
Resultsets nested within resultsets?
SQLException Exhausted resultset
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter