Saurabh
Saurabh

Reputation: 37

Improve Performance

In my Java project there are so many classes and every class requires a common value to display the data like (NT_Login, Country, Location and Role) so for every class I am using the JDBC to get the value from AdminTable(SQL) like NT_Login, Country etc and then it displaying me the result. Am I doing correct ? Or at the starting of the project should I Call JDBC to get the values and then should I pass all the values as a parameter to the other class? I don't know the best possible way please suggest me even if there are other thing which I can try but It should be the standard method as per the Software Development.

    //This is what I am doing for all the class
    ClassFindAdmin admin = new ClassFindAdmin();
    AdminBean bean = admin.getUserDetails(userName);
    String country = bean.getCountry();`enter code here`
    String location = bean.getLocation();
    String role = bean.getRole();
    String name = bean.getUser_Name();

Upvotes: 2

Views: 83

Answers (2)

Sandeep Roy
Sandeep Roy

Reputation: 405

In my opinion, may be calling all the references from the database, at the initial point of execution is a great idea, which is pointed out by you. In this way, we do not need to look upon the jdbc, frequently. However, this approach may delay the execution of the project. Not sure, what should be the best approach.

Upvotes: 0

vineeth sivan
vineeth sivan

Reputation: 510

If these values are same across a session, then it is better to get the values once and set in session. That way you can avoid to go to the DB all the time.

Upvotes: 1

Related Questions