• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error java.sql.SQLException: Exhausted Resultset

 
sunil ingalagi
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi....
im trying to retrieve a row from oracle database but its giving me an error as Error java.sql.SQLException: Exhausted Resultset
when i select an item from jcombobox its giving me this error
the error is in the following block..........
please help me


private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {
try
{
con = DriverManager.getConnection("jdbcracle:thin:@localhost:1521:MyDatas","scott","tiger");
stmt=con.createStatement();
String selected_id = (String)jComboBox1.getSelectedItem();
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT tran_type,msc_type,resp,resp_desc,r_desc FROM reason_code WHERE r_code = '+ selected_id'");

rs.next();
{
jTextField1.setText(selected_id);
jTextField2.setText(rs.getString(1));
jTextField3.setText(rs.getString(2));
jTextField4.setText(rs.getString(3));
jTextField5.setText(rs.getString(4));
jTextArea1.setText(rs.getString(5));

}
con.close();
}
catch(Exception e)
{
System.out.println("Error " + e);
}


}






THANKS in advance............
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to replace





Your query does not return a value (more on that later).
The rs.next() call returns false in that case, but you don't check it.




The query you send to the database is:


There will be no record whith r_code = '+selected_id'.

Please read the documentation for PreparedStatement.
There, you can read how to set a parameter in a query.
Using Prepared Statements






Regards, Jan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic