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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:35:51+00:00 2026-05-23T11:35:51+00:00

My application is not using any form of connection pooling, I’m working directly with

  • 0

My application is not using any form of connection pooling, I’m working directly with connections. The application does mainly short, simple queries. From the log I can see that it frequently opens and closes connections, often performing only a single select of one or a few rows in between. These take typically ~100ms (including opening and closing the connection).

There are countless articles and blog entries on how connection pooling improves application performance, but they all seem to be rather old (5 or more years).

Does connection pooling still provide a reasonable performance benefit or had it become obsolete. I’m using SQLServer 2008 with Microsofts JDBC driver version 3.0, if that matters.


Results/Update: Many things happened since I have asked this question (we switches JDBC driver and lots of other stuff). At some time I did lots of refactorings and other stuff and at that apportunity also added connection pooling to that application.
With connections pooling some queries execute now faster than the log timestamp granularity can measure (less than 16ms I believe).

So in conclusion, yes connection pooling is still worth the effort if you need to connect/disconnect frequently.

  • 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-23T11:35:52+00:00Added an answer on May 23, 2026 at 11:35 am

    If 100 ms per query is fine for you, then you don’t need a connection pool. If you need queries which are less than 20 ms, reusing connections is essential.

    If your driver supports its own connection pool, I suggest you use that (in case it doesn’t do this for you already). Only if you want greater control over how connections are pooled you can use an additional library (never found a good use for one myself)

    Note: you need not use a pool to re-use connections.

    One simple way to reuse connections is to have one persistent connection (which has appropriate thread safety guards in place) If your queries are infrequent, this may be all you need.

    If you want to be able perform queries concurrently and only have a few threads which will perform queries, you can store a connection in a ThreadLocal field.

    If you want multiple connections and you have more threads which could perform a query than you want to have in connections, use a pool.

    For the ThreadLocal model you can do

    public static final ThreadLocal<Connection> CONNECTION = new ThreadLocal<Connection>() {
         public Connection initialValue() {
             LOG.info(Thread.currentThread()+": created a connection.");
             return createConnection();
         }
    };
    

    If you want to control how the connections are cleaned up.

    private static final Map<Thread, Connection> connections = new ConcurrentHashMap();
    public static final ThreadLocal<Connection> CONNECTION = new ThreadLocal<Connection>() {
         public Connection initialValue() {
             LOG.info(Thread.currentThread()+": created a connection.");
             Connection conn = createConnection();
             connections.put(Thread.currentThread(), conn);
             return conn;
         }
    };
    public static void cleanUp() {
         for(Map.Entry<Thread, Connection> entry: connections.entrySet()) {
             Thread t = entry.getKey();
             if (!t.isAlive()) {
                 LOG.info(t+": closed a connection.");
                 connections.remove(t);
                 entry.getValue().close();
             }
         }
    }
    

    If you are concerned about getting a dead connection, you can override the get() of ThreadLocal to test the connection before returning.

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

Sidebar

Related Questions

My asp.net application is not using formsauthentication. Instead we make a call to database,
I am using GWT for my client side application. I am not using GWT/Java
I am currently writing a wizard-style application using Qt4. I am not using the
I've been asked to investigate a design for an ASP.NET (not MVC) application using
I am writing an application in C++ with using GTK+ (not gtkmm) so I
I would like to multi-thread an application, however one library i'm using is not
I've got an application using sockets (which I did not write, so bear with
I'm not a fan of using ASP.NET session state, but our application is using
I'm developing an IFrame application in Facebook (using pyfacebook and Django) and could not
I want to write an application using openstreetmaps rather than mkmapview, but I'm not

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.