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

The Archive Base Latest Questions

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

I have written a web app using Java EE for altering the contents of

  • 0

I have written a web app using Java EE for altering the contents of a table. For user authentication I am using the database credentials of the user. I am creating the JDBC connection using these credentials.

The problem arose when two or more user simultaneously logged in and the Connection object got updated with the credentials of the latest user. So no matter which user made the changes, the username of the latest user gt logged in the log file, which is a massive security issue.

So how can I create multiple Connection objects for multiple users so that the only username of the user who is making the modification gets in the log.

  • 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-10T20:07:14+00:00Added an answer on June 10, 2026 at 8:07 pm

    This sounds as if you were storing a reference to your connection objects in a static variable, keeping just a single connection object in your web application. Instead of that, you can make use of HttpSession to store a user-specific connection object in user’s session as an attribute. Store the connection there at the first time user accesses the application, then, at each subsequent request, get the connection back, check if it is still valid and use it.

    Also do not forget to close the connection once the session timeouts. This can be achieved by implementing a HttpSessionListener that checks for any connections in session and closing it in sessionDestroyed() method.

    EDIT: For multiple reasons, it is usually not a good design to use DB credentials to let users log on to an application. However, with low number of sessions (and thus low number of connections simultaneously opened on the DB) and with DB rights reasonably set, this still might work well.

    EDIT 2: And of course, access to such a cached connection needs to be synchronized (say, in case a user tries to hit your app with multiple simultaneous requests, e.g. by having multiple browser windows open). This might be a (little) tricky.

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

Sidebar

Related Questions

I have web application written in java using Eclipse. It has just one servlet
Say I have a mobile web app written using JQuery Mobile, this app retrieves
I have written a web app using the 'bleeding edge' HTML5/WebRTC API's (See code
We have an old web app written in classic ASP. We don't have the
I have a legacy intranet web app that was written for IE7 and contains
I have written code in Java to access web cam,and to save image... I
I have a very large problem. I've written a large app using Flex3/Tomcat/BlazeDS/Spring that
I am calling a web service (written in Java) in my web app. I
I have a web app which orders stuff using a timestamp, which is just
I have recently inherited a J2EE Struts web app that was written back in

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.