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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:52:12+00:00 2026-06-10T18:52:12+00:00

I have to create a web app that connects to a MySQL DB. I

  • 0

I have to create a web app that connects to a MySQL DB.
I was wondering how I should handle the connection object in my DAOs.

The application is likely to be used a few times a day by different users.

I am a bit troubled with the DAO pattern and using a static singleton. As it is a web app, I would have a connection to the DB permanently. I feel that it s not so good to keep this connection up and shared between all users sessions.

On the other hand, I’m not so sure that getting the connection and closing it every time I need to access the Db is really a better idea.

Is one way better than the other? did I forget anything that could be better?

  • 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-06-10T18:52:13+00:00Added an answer on June 10, 2026 at 6:52 pm

    Normally you will have datasource setup in your container, and for each operation, just get connection from the datasource. With correct transaction manager setup, connections retrieved under same transaction should be the same. Connection pooling is normally handled in the datasource.

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

Sidebar

Related Questions

I have a mod_perl2 based web app that requires a connection to a mysql
I have recently changed my web app to create a database connection per command
I have a Java web application that has a 'disconnected' Java Swing desktop app.
I have create web app in MVS 3 but failed to display alert message
I have a web app where people can create custom content on the web
So I have a simple web app where I can create a user (UserModel)
I'm attempting to create a web application with TweetSharp that will connect to Twitter
I have created a web app that authenticates users on our page and I'd
I am writing an application that connects to a web service in a background
I have a Web Application that I'm trying to move from Sun Application Server

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.