wood burning stoves 2.0*
The moose likes JDBC and the fly likes Error java.sql.SQLException: Exhausted Resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error java.sql.SQLException: Exhausted Resultset" Watch "Error java.sql.SQLException: Exhausted Resultset" New topic
Author

Error java.sql.SQLException: Exhausted Resultset

sunil ingalagi
Greenhorn

Joined: Apr 23, 2008
Posts: 17
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

Joined: Dec 20, 2006
Posts: 2491
    
    8

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


OCUP UML fundamental and ITIL foundation
youtube channel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error java.sql.SQLException: Exhausted Resultset
 
Similar Threads
Fail to convert to internal representation
Selecting next record from a table
JDBC - Retriving data from Database
cannot retrieve table from my java program
getActionCommand() this is not working in code