java - How come taxPercentage variable is being returned as null? -


the purpose of code below evaluate tax perecentage based on given salary, "converted_basic_pay". seems working fine values except last row, has null value salary bigger 15001. however,for testing purposes set value of converted_basic_pay 20000, it's still returning null instead of maximum tax percentage. tax table in sql:

enter image description here

float taxpercentage = 0; preparedstatement ps6 = con.preparestatement("select taxpercentage payroll_system.tax_info ? between fromsalary , tosalary"); ps6.setint(1, converted_basic_pay); resultset rx = ps6.executequery(); if (rx.next()){       preparedstatement ps7 = con.preparestatement("select max(taxpercentage) maxtax, max(fromsalary) maxfrom payroll_system.tax_info");      resultset rx1 = ps7.executequery();      if(rx1.next()){         float maxtax = rx1.getfloat("maxtax");         float maxfrom = rx1.getfloat("maxfrom");         if(converted_basic_pay>maxfrom){             taxpercentage = maxtax;         }         else{             taxpercentage =rx.getfloat("taxpercentage");         }         out.println(taxpercentage);          }                } } 

the value of converted_basic_pay 20000. how come last line, out.println(taxpercentage) returning null value instead of 45.00?


Comments