Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8657995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:39:32+00:00 2026-06-12T15:39:32+00:00

I have a program in which I have to retrieve data from database. I

  • 0

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….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:39:33+00:00Added an answer on June 12, 2026 at 3:39 pm

    The way to debug this is as follows:

      String str = "9035";
      while (rs.next()) {
            String areaCode = rs.getString("AreaCode");
            if(str.equals(areaCode)){
               System.out.println("!!!!!!It matched: " + str);
               break;
            } else {
               System.out.println("No match with: " + areaCode);
            }
      }
    

    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

    select count(0) as tot from your_table_name where AreaCode = '9035'
    

    and then with the ResultSet of that do

    if(rs.getInt("AreaCode") != 0){
      //found the/a match
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that needs to retrieve some data about a set of
I have two mdi applications, both of which retrieve their data from the same
I have a program which is able to retrieve various registry values using C#
Which options do I have to retrieve the data from PHP to Objective-C? Until
In my google maps program I have simple KML parser which retrieve only coordinates
I am trying to retrieve values from my App.config file which is stored in
I have a database with employee information and a program, which is supposed to
I wrote a Java program to add and retrieve data from an MS Access.
I have an application which connects to a database, retrieves a username from a
I have a program which creates JButtons which are then added to a JPanel

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.