Example :
Method :
Method :
DefaultTableModel table = new DefaultTableModel();jTable1.setModel(table);table.addColumn("a");table.addColumn("b");table.addColumn("c");table.addColumn("d");table.addColumn("e");table.addColumn("f");table.addColumn("g");try {Connection connect = Connect.getConnect();String sql = "SELECT * FROM other";Statement stat = connect.createStatement();ResultSet res = stat.executeQuery(sql);while (res.next()) {table.addRow(new Object[]{res.getString(1), res.getString(2), res.getString(3), res.getString(4), res.getString(5), res.getString(6), res.getString(7)});setVisible(true);}} catch (Exception e) { JOptionPane.showMessageDialog(null,e);}
No comments:
Post a Comment