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 1048651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:29:29+00:00 2026-05-16T16:29:29+00:00

I am now working on a web application project for the first time, the

  • 0

I am now working on a web application project for the first time, the application includes registering and adding users to the database, now i wrote a java class called DatabaseManager that implements all database operations, and wrote the JSP page responsible for adding new users, if the registration is successful I need to add the user’s details to the database, so I was wondering, do I need to create a instance of DatabaseManager and load the database driver and initialise the connection everytime a new user registers or is there a more efficient way to do it?

thanks

  • 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-05-16T16:29:30+00:00Added an answer on May 16, 2026 at 4:29 pm

    Loading the database driver can be done just only once during webapp’s startup. You can use a ServletContextListener for this. You could do the driver loading task in the constructor of the DatabaseManager class and instantiate it during contextInitialized() and store the instance in the application scope so that it is available to all servlets in the context (noted should be that JSP is in essence the wrong place for business logic).

    Opening (and closing!) the Connection should really be done directly in the very same method block as you’re executing the SQL query. It should certainly not be “cached” as a static/instance variable somewhere in your application logic. To improve connecting performance, the normal practice is to configure a connection pool to obtain the connections from. In every decent servletcontainer you can do this in flavor of a JNDI datasource.

    Long story short, you can find a JSP/Servlet example utilizing the above techniques in this article which is by coincidence also using an use case of “register user”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.