I have a database table which has many patient details like registration id, registration date etc. I want to perform a date based search of the patients and get the result into a jTable. ( for example, if I type 23-05-2013 as the registration date, all the patients admitted on 23 May should be displayed in a jTable. How do I do that?
This is the code I have used:
public void getTableData() {
  try {
     con = getConnection.getCon();
     String sql = "SELECT * FROM patientrecords WHERE Registration Date = ?";
     pst.setString(1, regdate.getText());
     pst = con.prepareStatement(sql);
     rs = pst.executeQuery();
     if (rs.next()) {
        patient_table.setModel(DbUtils.resultSetToTableModel(rs));
     }
  } catch (SQLException e) {
     JOptionPane.showMessageDialog(null, e);
  }
}
 
     
    