aspose file tools*
The moose likes JDBC and the fly likes cannot retrieve table from my java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "cannot retrieve table from my java program" Watch "cannot retrieve table from my java program" New topic
Author

cannot retrieve table from my java program

sunil ingalagi
Greenhorn

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

Joined: May 26, 2003
Posts: 31062
    
232

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 + "'");


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
sunil ingalagi
Greenhorn

Joined: Apr 23, 2008
Posts: 17
Thank you very much Jeanne you solved my problem.............
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot retrieve table from my java program