• 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

cannot retrieve table from my java program

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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("jdbc:oracle: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
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much Jeanne you solved my problem.............
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic