0

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);
            }
Noor
  • 1
  • 1
  • Welcome to stakeoverflow, take a [tour](https://stackoverflow.com/tour) to understand how so works. [guide - how can I ask](https://meta.stackoverflow.com/questions/334822/how-do-i-ask-and-answer-homework-questions), we are here to help you out but need some efforts before posting a question [research](https://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) and also check out a [things to keep in mind to post a good question](https://stackoverflow.com/help/how-to-ask), for any other help [visit](https://stackoverflow.com/help/) – Error Hunter Jul 06 '21 at 10:02

0 Answers0