| 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("jdbc racle: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: 2343
|
|
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
ITIL foundation
|
 |
 |
|
|
subject: Error java.sql.SQLException: Exhausted Resultset
|
|
|