Press "Enter" to skip to content

Ascending & descending operation using java gui.

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

Leave a Reply

Your email address will not be published. Required fields are marked *