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);
}
Read from database is fixed now but the ID which is 1 to 312 the numbers on the jtable don't come in order as in database.How can i fix this?
the ID which is 1 to 312 the numbers on the jtable don't come in order
The only way to guarantee the order in which rows are returned by a SQL statement is to include an ORDER BY clause. In your case you need to add ORDER BY ID
to the end of your SQL statement.