• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exhausted Resultset

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I do have the following table called mass_price

>desc mass_price

Name Null Type
------------------------------ -------- -------------------
PRICE_ID NUMBER
ORDER_ID VARCHAR2(40)
PRICE NUMBER(19,7)
RESPONSE VARCHAR2(4000)

>select price_id, order_id, price from mass_price order by price_id asc

PRICE_ID ORDER_ID PRICE
---------------------- ---------------------------------------- ----------------------
1 12090001 100
2 12100001aa 101
3 12100001 101


I do have the following piece of code to access some rows and do some processing

.........
.........
.........

String priceId;
String orderId;
String price;

try {
Connection connection = DriverManager.getConnection(oracleURL, username, password);
Statement selectStatement = connection.createStatement();
String query = "select price_id, order_id, price from mass_price order by price_id asc";
ResultSet resultset = selectStatement.executeQuery(query);


while ( resultset.next() ){

System.out.println( "price_id: "+resultset.getString("price_id") ) ;
System.out.println( "order_id: "+resultset.getString("order_id") ) ;
System.out.println( "price: "+resultset.getString("price") ) ;

priceId = resultset.getString("price_id");
orderId= resultset.getString("order_id");
price = resultset.getString("price");

try {

.......
.......


}catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}// while loop

connection.close();


} catch (SQLException ex) {
// TODO Auto-generated catch block
ex.printStackTrace();
}



I am getting
java.sql.SQLException: Exhausted Resultset

at line
System.out.println( "price_id: "+resultset.getString("price_id") ) ;

Can somebody help me to find out why?
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please provide full stack trace.. (exception)

 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are some JDBC drivers which only allow you to read a column once from a row. (Note that you're reading each of the columns twice in your code.) Or perhaps it's that they require you to read the columns in order... anyway, just change your code to read each of the columns, once, into a variable. That should make the error go away (and make the code a little easier to read too).
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:There are some JDBC drivers which only allow you to read a column once from a row.



The same point was blinking in my mind but I wasn't sure.

Thanks Paul..

 
Alex George
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That seems to be working.
Thanks to everybody.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic