I want to get data from Ms Access using search button in java I have tried this code but it show java.lang.NullPointerException How to Fix.
try{
conn = Connectivity.getConnection();
String sql = "Select * from Patient Where ID = '"+search_id_1+"'";
rs = stat.executeQuery(sql);
if(rs.next()){
search_id_2.setText(rs.getString("ID"));
search_name.setText(rs.getString("Patient_Name"));
search_address.setText(rs.getString("Patient_Address"));
search_virus.setText(rs.getString("Coivd_Effected"));
}else{
JOptionPane.showMessageDialog(null,"Record not found");
}
}catch(Exception e){
JOptionPane.showMessageDialog(null,e);
}