This is my code that doesn't do anything :). It should generate a table with appointments both assigned and free.My database name is test, table name is programari, column name for date is data, column name for hour is ora and column name for user is pacienti.
private void refreshTable(){
String[] orar={"8:00","8:30","9:00","9:30","10:00","10:30","11:00","11:30","12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00","20:30","21:00","21:30","22:00"};
DefaultTableModel model = new DefaultTableModel();
model.setRowCount(0);
try {
for(int i =0;i<orar.length;i++){
pst=conn.prepareStatement("select * from programari");
rs=pst.executeQuery();
if(rs.next()){
if(rs.getDate("data").toString().equals(datap.getDate().toString())){
if(rs.getString("ora").equals(orar[i])){
model.addRow(new Object[]{orar[i],rs.getString("pacienti")});
}else{
model.addRow(new Object[]{orar[i],null});
}
}
}else{
model.addRow(new Object[]{orar[i],null});
}
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}