private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
      
         try{
         Class.forName("com.mysql.jdbc.Driver");    
         conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/library_management", "root", "welcome6" );
         
         if (jTextField1.getText().isEmpty())
                 {
                     JOptionPane.showMessageDialog(this, "Enter a valid card number");
                     return;          
                 }
         
         int card_no =Integer.parseInt(jTextField1.getText());
         String s0 = "select * from borrower where card_no =?";
         PreparedStatement p0 = conn.prepareStatement(s0);
         p0.setInt(1, card_no);
         ResultSet r0 = p0.executeQuery();
         
         if(!r0.next())
         {
             JOptionPane.showMessageDialog(this, "Enter a valid card number");
                     return;   
             
         }
         r0.previous();
         
         jList1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
jList1.setLayoutOrientation(JList.VERTICAL_WRAP);
jList1.setVisibleRowCount(-1);
DefaultListModel listModel = new DefaultListModel();
         while(r0.next())
         {
             
             
             
            listModel.addElement("NAME:\n");
            listModel.addElement(r0.getString(2) + r0.getString(3));
             listModel.addElement("\n");
            listModel.addElement("ADDRESS:\n");
            listModel.addElement(r0.getString(4));
            listModel.addElement(r0.getString(5) + "," + r0.getString(6));
            listModel.addElement("\n");
            listModel.addElement("PHONE NUMBER:\n");
            listModel.addElement(r0.getString(7));
            
             
         }
         
         float paid_fine;
         float unpaid_fine;
         boolean x=true, y =false;
         
         paid_fine=(float)0;
         unpaid_fine=(float)0;
         String s1 ="select fine_amount from book_loans,fines where book_loans.loan_id=fines.loan_id  and card_no=? and paid =?";
         PreparedStatement p1 = conn.prepareStatement(s1);
         p1.setInt(1,card_no);
         p1.setBoolean(2,x);
         
         ResultSet r1 = p1.executeQuery();
         
         while(r1.next())
         {
             paid_fine = paid_fine + r1.getFloat(1);
            
                     
         }
          listModel.addElement("\n");
          listModel.addElement("FINE PAID:\n");
          listModel.addElement(String.valueOf(paid_fine));
         String s2 ="select fine_amount from book_loans,fines where book_loans.loan_id=fines.loan_id  and card_no=? and paid =?";
         PreparedStatement p2 = conn.prepareStatement(s2);
         p2.setInt(1,card_no);
         p2.setBoolean(2,y);
         
         ResultSet r2 = p2.executeQuery();
         
         while(r2.next())
         {
             unpaid_fine = unpaid_fine + r2.getFloat(1);
                    
         }
         listModel.addElement("\n");
         listModel.addElement("FINE PENDING:\n" );
        listModel.addElement(String.valueOf(paid_fine));
         
         jList1.setModel(listModel);        
         conn.close();// End while(rs.next())
        
       
        
        
        }
        catch(SQLException ex) {
			System.out.println("Error in connection: " + ex.getMessage());
		}
        catch (ClassNotFoundException ex)
        {
            System.out.println("Class not found:" + ex.getMessage());
        } 
         
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
    }//GEN-LAST:event_jButton1ActionPerformed