I have to compare user entered id with database id

user2221047

I have to compare user entered id with database id, but I have not get result and unable to return result properly, and can't do this with below code so please tell me how to do

public String execute() throws Exception {
    isValid = doProcessing(getUserid());

    return SUCCESS;
}

public boolean doProcessing(String userid) throws Exception {
    Connection con = null;
   // ResultSet rs = null;
    PreparedStatement pstmt = null;
    boolean status=false;
    try {
        con = ConnectionDB.createConnection();
        pstmt = con.prepareStatement("select userid from attestedform where userid=?");
        pstmt.setString(1, userid);
        ResultSet rs = pstmt.executeQuery();


        request = ServletActionContext.getRequest();
        session = request.getSession();
        String s = (String) session.getAttribute("UsrBeanLoginId");


        while (rs.next()) {
            id = rs.getString("userid");

            if (s.equalsIgnoreCase(id)) {
                status = true;


            } 
            else
            {

                status=false;
            }

        }

    } catch (Exception e) {
        e.printStackTrace();
    } 
    return status;
   }
   }
Roman C

You are comparing different value.

I have to compare user entered id with database id

Change your code

while (rs.next()) {
    id = rs.getString("userid");

    if (userid.equalsIgnoreCase(id)) {
        status = true;
    } 
    else
    {
        status=false;
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

I want to combine two tables by selecting the id entered by the user in Laravel

Save logged in user's id to database when I have $request->all()

I have firebase user id, but I can't access name

I have problem to send multiple users id into database using laravel

How do I echo rows that have a specific ID in it from Database

How do I fix my code so it allows me to grab the user's id who entered the command?

I am trying to compare sport_id in user table but sport_id are store in array how can i compare with php

How can I fetch user id which have two values

my user_id profile database is null, how i insert the value in user_id?

How do I query Realm database based on current user ID?

I want to print user's ID from database on one modal

Altering database based on user id

Is there a database of steam user ID's?

Laravel 5 says: "Unknown column 'user_id' in 'field list'", but I have 'author_id'

Display data from database depending on the how many I have entered

Mysql display values if i have only user entered value

How can I delete a like from my database if user_id and post_id are the same?

How do i have my bot send a message to any user by typing their user id on command?

How do I add a role to a user with a discord bot in java if I have their ID as a String?

I have a javascript object, and I want to find a user by id and update their balance

Laravel - How can i set the Auth::attempt to a user if i only have a JWT token with the email and the id

QCompleter, how to have the Id from a database

show data if you have user id - laravel

how to get multiple data with same user id from a table in nest js? suppose i have a user table .how can I get user id matched data?

How do I get the last id entered with Dapper?

Laravel check if user have user name if not show user id excel

The user with id # does not have the right view on profile with id #

How to prompt the user again to enter the right ID if invalid and stops the loop when entered the right ID

In SQL, how do I select unique user id when it may have two different observations?