I have a program in which I have to retrieve data from database. I have retrieved it in the form of String. This String Contains Some 100 Values. Now I have to compare these values with the values of the String given by me . If The values matches then it should execute the if condition, otherwise not.
here is my code…
String str = "9035"; Manually Given by me.
AreaCode = rs.getString("AreaCode"); Retrieved from database with 100 records..
I am using if(AreaCode.equals(str)) but it’s not working….
The way to debug this is as follows:
From you question it looks like you are just comparing the first record, what you need to do is iterate through each result as above and compare. Once you find the record you exit the loop with the break statement.
Of course a better solution is to do a select using a where clause that include the areaCode, if you get a record back then it is in there, if not, the you know it isn’t.
Something like
and then with the ResultSet of that do