• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot retrieve table from my java program

 
sunil ingalagi
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..beginner in java programming...
i have written java pgm to update and delete records from frame.
i have created a column called 'r_code' in 'reason_code' table in oracle database. i can access all r_code data in jComboBox but it is giving me sqlException as Error java.sql.SQLException: ORA-01722: invalid number

im getting error in following block

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);
}


}
-------------------------------------------
please help me to solve this problem
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sunil,
Welcome to JavaRanch!

Is the code a number or can it have letter in it?

If the later it should be:
... WHERE r_code = '" + selected_id + "'");
 
sunil ingalagi
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Jeanne you solved my problem.............
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic