Source code of ascending & descending operation in java gui.
Ascending code…
try{
String sql = "select * from user order by f_name ASC";
pst = con.prepareStatement(sql);
rs = pst.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(rs));
}catch(SQLException e){
JOptionPane.showMessageDialog(null, e);
}
Descending code…
try{
String sql = "select * from user order by age DESC";
pst = con.prepareStatement(sql);
rs = pst.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(rs));
}catch(SQLException e){
JOptionPane.showMessageDialog(null, e);
}
Interface of after run the page.
Be First to Comment