0

I have developed a login page which needs to access the database for login information. I have put all the user authentication functions in my DAO class which is a singletone class

class DAO { //DAO is a singletone class

    public boolean authenticateUser(username,password) {
        //authentication process done here
    }
}

Whenever the user presses the Login button, the form submits to the server and I have written this code to check the authenticity using DAO class

DAO loginChecker = DAO.getInstance();
boolean validUser = loginChecker.authenticateUser(username,password);

Now my question is, can this design handle hundreds of simultaneous user logins?? because DAO seems to be running in a single thread. If not, could you suggest me some ideas about how to design this DAO class so that it can handle many simultaneous user logins??
Thanks.

3
Contributors
6
Replies
25
Views
4 Years
Discussion Span
Last Post by cool_zephyr
0

Now my question is, can this design handle hundreds of simultaneous user logins?? because DAO seems to be running in a single thread. If not, could you suggest me some ideas about how to design this DAO class so that it can handle many simultaneous user logins??

My question is very simple is this related to any forum or some sort of social media website? If so, then you to see whether DAO will work on that platform.

0

no, it's for a website..the DAO handles all the database related queries for every page of the website..
should i do

DAO dao=new DAO();

for every session or DAO

dao=DAO.getInstance();

???

0

cool zephyr: do you even know what a Singleton is? just by adding 'this is a singleton' in a comment doesn't make it one.
so. were you planning on making it a singleton or not?

0

i know how a singleton is made..since the actual question was if this design could handle hundreds of simultaneous database connections, i prefered to exclude it as writing full code for singleton was irrelevant

public class DAO {
    private DAO singleton=null;
    private DAO() {
        //initialization
    }
    public static DAO getSingleton() {
        if(singleton==null)
            singleton=new DAO();
        return singleton;
    }
}
0

well, without adding a 'static' extra in there, that won't really work.
what exactly are you afraid of? that two calls will run simultaneously? looks to me like you should take a look at synchronization.

0

yeah you got me in that one :)
you got it right..i'm thinking if this design can handle 1000 simultaneous dao.authenticate(..), because all the uses who have to sign in must use this singleton DAO..if I put on synchronization will it handle that many connections??

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.