How to add new rows into a jTable from database while button click without clearing existing rows
How to add new rows into a jTable from database while button click without clearing existing rows in jTable? I tried lot of ways. But no success. Help String SQL = "SELECT name,price FROM items WHERE ID = ' "+jTextField1.getText()+" ' "; pst = Conn.prepareStatement(sql); rs = pst.executeQuery(); jTable1.setModel(DbUnits.resultSetToTableModel(rs)); Edit:- With the help of all answers i change the code into below code, But OK . But here i get a error in DefaultTableModel String sql = "SELECT name,price FROM items WHERE ID = '"+jtxt1.getText()+"'"; pst = conn.prepareStatement(sql); rs=pst