By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,654 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,654 IT Pros & Developers. It's quick & easy.

updating database table from jtable in netbeans

100+
P: 126
how do we update the back-end table from front-end jtable?
i'm using the following things in my project -
editor- netbeans 7.2
framework - core java
database - mysql 5.0.96

my question-
i have a jtable with just one column made editable, when the user edit's the content of the table from front-end i want to update my table in back-end with the edited value, and how do i do it?
Nov 1 '12 #1
Share this Question
Share on Google+
1 Reply


100+
P: 126
I solved the problem, below is the code :

Expand|Select|Wrap|Line Numbers
  1.  
  2. for (int i = 0; i < jTable1.getRowCount(); i++) 
  3. {
  4. System.out.println(" jtable row " + i);
  5. String qty = jTable1.getValueAt(i, 3).toString();
  6. String query4 = "update " + cartnumber.getText() + " set quantity = " + qty + " where rfid_no = 
  7. "+jTable1.getValueAt(i, 0) + " 
  8. and name = '" + jTable1.getValueAt(i, 1) + "'";
  9. st4.executeUpdate(query4);
Nov 6 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.