updating database table from jtable in netbeans

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PreethiGowri
    New Member
    • Oct 2012
    • 126

    updating database table from jtable in netbeans

    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?
  • PreethiGowri
    New Member
    • Oct 2012
    • 126

    #2
    I solved the problem, below is the code :

    Code:
     
    for (int i = 0; i < jTable1.getRowCount(); i++) 
    {
    System.out.println(" jtable row " + i);
    String qty = jTable1.getValueAt(i, 3).toString();
    String query4 = "update " + cartnumber.getText() + " set quantity = " + qty + " where rfid_no = 
    "+jTable1.getValueAt(i, 0) + " 
    and name = '" + jTable1.getValueAt(i, 1) + "'";
    st4.executeUpdate(query4);

    Comment

    Working...