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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:15:32+00:00 2026-05-29T09:15:32+00:00

I have a web application that needs a database back-end. My back-end is really

  • 0

I have a web application that needs a database back-end.
My back-end is really small (max 4 tables) and the SQL operations are not that much.
So I decided that some robust ORM solution is like hitting a moschito with a hummer and I am going just to do a little DAO pattern so that the code is more clean (instead of hitting the db directly with sql commands).

So far it works but I am not sure that I haven’t stepped into a pittfall without knowing.
I use Tomcat’s connection pool and I expect concurrent access to the database.

My question is related to concurrency and the use of the java sql objects.

Example:

I do the following:

  • do a query
  • get a result set and use that to build an object (dto)
  • building this object I do a new sql query (using the same connection
    and having the previous resultset open)

Is this correct/safe?

Also can I reuse the same connection in a re-entrant manner?
I assume it is no problem to use it via multiple threads right?

Generally any tips/guide to get in the right track is welcome

  • 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-29T09:15:32+00:00Added an answer on May 29, 2026 at 9:15 am

    Regarding the connections, as long as you use the connection pool you are guaranteeing that each thread takes its own connection, so from that point of wiew, there is no problem in your approach in a multithreaded environment (you can check Is java.sql.Connection thread safe?).

    With respect to the ResultSet and the second query you are performing, you must take into account that a ResultSet maintains a cursor pointing to its current row of data. So the key point in your question is if you are using the same “SELECT statement”, because of in that case, you could get the same cursor attributes and some problems may arise.

    Check ResultSet’s javadoc, especially this sentence:

    A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results.

    and How can I avoid ResultSet is closed exception in Java?.

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

Sidebar

Related Questions

I have a web application that needs to fire off a long-running SQL Server
I have a web application that needs to take a file upload from the
I have a web application that uses the current version of JQuery that needs
I have a C# web application that needs to deploy a file to the
I have a page in my vb.net web application that needs to toss a
So I have this c# application that needs to ping my web server thats
We have developed a .NET web application that uses SQL Server as a backend.
I have an ASP.NET MVC Web Application that interacts with a SQL Server 2008
I have a program that uses a Microsoft Access database for its back-end. I
I have a .NET application with a web front-end, WCF Windows service back-end. 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.