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.

Recommended Answers

All 6 Replies

Member Avatar for LastMitch

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.

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();

???

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?

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;
    }
}

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.

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??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.