如何以正确的顺序显示来自 Access 的数据?
How to show data from Access in the correct order?
String sql="select ID,Hmerominia,Agores,Pliromes,Eksoda,Zhta,Metaforika,Pliromimetafo,Epitages,Xondriki,Noiki,Plirominoiki from Synola";
try{
pst = conn.prepareStatement(sql);
rs=pst.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(rs));
// JOptionPane.showMessageDialog(null, "Saved");
}catch(Exception ex){
JOptionPane.showMessageDialog(null, ex);
}
现在从数据库中读取已修复,但是 1 到 312 之间的 ID jtable 上的数字不按 database.How 中的顺序排列,我可以解决这个问题吗?
the ID which is 1 to 312 the numbers on the jtable don't come in order
保证 SQL 语句返回行的顺序的唯一方法是包含 ORDER BY 子句。在您的情况下,您需要将 ORDER BY ID
添加到 SQL 语句的末尾。
String sql="select ID,Hmerominia,Agores,Pliromes,Eksoda,Zhta,Metaforika,Pliromimetafo,Epitages,Xondriki,Noiki,Plirominoiki from Synola";
try{
pst = conn.prepareStatement(sql);
rs=pst.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(rs));
// JOptionPane.showMessageDialog(null, "Saved");
}catch(Exception ex){
JOptionPane.showMessageDialog(null, ex);
}
现在从数据库中读取已修复,但是 1 到 312 之间的 ID jtable 上的数字不按 database.How 中的顺序排列,我可以解决这个问题吗?
the ID which is 1 to 312 the numbers on the jtable don't come in order
保证 SQL 语句返回行的顺序的唯一方法是包含 ORDER BY 子句。在您的情况下,您需要将 ORDER BY ID
添加到 SQL 语句的末尾。