How to populate JTable from ResultSet?

I think the simplest way to build a model from an instance of ResultSet, could be as follows. public static void main(String[] args) throws Exception { // The Connection is obtained ResultSet rs = stmt.executeQuery(“select * from product_info”); // It creates and displays the table JTable table = new JTable(buildTableModel(rs)); // Closes the Connection JOptionPane.showMessageDialog(null, … Read more

Last row always removed from DefaultTableModel, regardless of index

The row obtained from columnAtPoint() is in view coordinates, while removeRow() assumes model coordinates. Quoting from the relevant tutorial section: This distinction does not matter unless your viewed data has been rearranged by sorting, filtering, or user manipulation of columns. If so, you will need to use convertRowIndexToModel(), described near the end of Sorting and … Read more

Most simple code to populate JTable from ResultSet

I think the simplest way to build a model from an instance of ResultSet, could be as follows. public static void main(String[] args) throws Exception { // The Connection is obtained ResultSet rs = stmt.executeQuery(“select * from product_info”); // It creates and displays the table JTable table = new JTable(buildTableModel(rs)); // Closes the Connection JOptionPane.showMessageDialog(null, … Read more