Results 1 to 3 of 3
- 02-02-2011, 05:14 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 7
- Rep Power
- 0
retrivieving from oraclexe database table to data program
i try to retrieve data from a database to my java program but the code doesn't seem to work no error but it just doesnt work
here is the code
try {
String nam = jComboBox9.getSelectedItem().toString();
st2 = con.createStatement();
rs1 = st2.executeQuery("select * from member2 where name = "+ nam +" " );
rs1.next();
jComboBox9.addItem(rs1.getString(1));
jTextArea3.setText(rs1.getString(2));
jComboBox10.setSelectedItem(rs1.getString(3));
jComboBox11.setSelectedItem(rs1.getString(4));
jTextField20.setText(rs1.getString(5));
jTextField21.setText(rs1.getString(6));
} catch (SQLException ex) {
Logger.getLogger(CPM.class.getName()).log(Level.SE VERE, null, ex);
}
- 02-02-2011, 06:53 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
For starters, shouldn't a value be put in single quotes? having said that, it reminds me of this.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 02-03-2011, 08:23 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
Debug it.
Print out the values.
As Jos says, I doubt that SQL will run so you ought to be getting an exception. Where it's going (are you logging to a file?) I have no idea.
ETA: Oh yes, and this is one of the reasons for keeping display logic separate from db logic.
Make a DAO (Data Access Object) that gets the data you want from the db and creates a List of a suitable class which it returns.
The display can then show the data based on this list and not care where it comes from.
In addition you'll be able to test the db logic in isolation since it won't care what's done with that data.
Oh...and PreparedStatement.Last edited by Tolls; 02-03-2011 at 08:25 AM.
Similar Threads
-
error in reading data from table in pidgree database
By chethan_kc in forum Java ServletReplies: 17Last Post: 02-18-2011, 02:11 PM -
Connecting to a database table
By kiz106 in forum JDBCReplies: 1Last Post: 05-19-2010, 10:33 AM -
How to display database in table
By tamnc in forum SWT / JFaceReplies: 0Last Post: 03-15-2010, 05:57 AM -
Modifying data in database table using PreparedStatement
By Java Tip in forum Java TipReplies: 0Last Post: 02-09-2008, 08:22 PM -
Plz help ... retreiving data from an access database table....
By austinsmiles in forum New To JavaReplies: 1Last Post: 02-01-2008, 01:21 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks