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

  • SEARCH
  • Home
  • 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 382421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:10:52+00:00 2026-05-12T15:10:52+00:00

I have a j2ee webapp that’s being used internally by ~20-30 people. There is

  • 0

I have a j2ee webapp that’s being used internally by ~20-30 people.

There is no chance of significant growth in the number of users.

From what I understood there’s a trade-off between opening a new DB connection for each request made to the webapp (expensive, but doesn’t block other users when the DB is in use), to using the singleton pattern (doesn’t open new connections but only allows one user at a time).

I thought that since I know that only 30 users will ever use my webapp at the same time, maybe the simplest and best solution would be to store the connection as a session attribute, thus reducing to a minimum the amount of openings made, while still allocating one connection per user.
What do you think?

  • 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-12T15:10:52+00:00Added an answer on May 12, 2026 at 3:10 pm

    From what I understood there’s a
    trade-off between opening a new DB
    connection for each request made to
    the webapp

    That is what connection pools are for. If you use a connection pool in your application, the pool once initialized, is in charge of providing connections for use in the application as and when needed. In a properly tuned connection pool, there are going to be enough connections created on reserve that can be provided to the application, mitigating the need to create and open a connection only when the application requests for it.

    I thought that since I know that only
    30 users will ever use my webapp at
    the same time, maybe the simplest and
    best solution would be to store the
    connection as a session attribute

    Per-user connections are not a good idea, primarily when a web application is concerned. In a web application, it is perfectly possible for users to initiate multiple requests to the server (think multi-tabbed browsing). In such a case, the use of a single connection per user will result in weird application behavior, unless you synchronize access to the connection.

    One must also consider the side-effect of putting transient attributes into the session – Connection objects are not serializable and hence must be marked transient. If the session is deserialized at some point, one has to account for the fact that the Connection object will not be available, and must be re-initialized.

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

Sidebar

Related Questions

I have a J2EE webapp which is used to download a generated PDF served
I have recently inherited a J2EE Struts web app that was written back in
I have a J2EE application that has a lot of reports, the situation now
I have a J2EE app deployed as an EAR file, which in turn contains
I have a J2EE application running on an IBM Websphere Application Server on a
We have a J2EE app built on Struts2+spring+iBatis; not all DAO's use iBatis...some code
we have a J2EE app on which we're still working. It runs on Oracle
I have a J2EE application with a web service which goes like http://servername/service?task=getFile&id=25 How
I have a j2ee application running on spring framework. I am trying to apply
I have a J2EE application front-ended by a bunch of GWT pages. When the

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.