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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:04:03+00:00 2026-06-05T09:04:03+00:00

I’ve been going at this for many many hours without success. I’m instantiating a

  • 0

I’ve been going at this for many many hours without success. I’m instantiating a DataSource in a multi threaded application. All threads get connections from the DataSource and close them in finally blocks (I’ve gone line by line to make sure that connections are released). The problem I’m having is that even though the close method is called on every connection theyr not being released by the DataSource. I know this because I have a different thread that prints the source.getNumActive() from the DBCP data source.

This is the basic setup.

public class DataSourceHolder {
  private static DataSource source;
  static {
    get the data source either from jndi or created from scratch
  }
  public DataSource getDataSource() { return source; }
}

I have a simple JdbcPattern (like springs JdbcTemplate but extremely simple) to encapsulate all boilerplate code. This is defined something like so:

public class JdbcPattern {
  private DataSource source;
  public JdbcPattern(DataSource source) {
    this.source = source;
  }
  public int executeMethods(....) {
    Connection c = source.getConnection();
    try {
      .. do the statements
    } finally {
      try { c.close(); } catch (SQLException ignore) { }
    }
  }
  public List<?> queryMethods(....) {
  }
}  

Finally I have four threads that get started at the beginning of the program. This threads sleep for a while and on wakeup instantiate a JdbcPattern with the DataSourceHolder provider DataSource and start doing stuff. The stuff gets done and when the connections is closed, it is not really released by the DataSource. After the DataSource max connections the program freezes due to no more connections can be instantiated.

How would you go about diagnosing this?

EDIT. This is running on tomcat. All the common methods are being loaded by catalina common loader and the threads are run inside one of the web applications. I’ve been thinking it might be a class loader problem.

  • 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-05T09:04:05+00:00Added an answer on June 5, 2026 at 9:04 am

    You shouldn’t ignore a failure to close. Wrap it in an unchecked exception or log it, but don’t ignore. If there was some odd error when trying to release the connection to the pool, you won’t know.

    I would recommend creating your own wrapper for the pool DataSource. You can log calls to getConnection along with a stack trace and a unique identifier of the connection. Also log the same way in your JdbcPattern when it calls close. Find the identifiers of the connections that are not closed, note where they are taken out of the pool from the getConnection stack trace. You could also make your DataSource wrapper do this analysis inside the server, but that is more code and more chance for error. I would try with simple logging first. Consider leaving this logging in the product, but below the normal logging theshold. You will need it again.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
This could be a duplicate question, but I have no idea what search terms
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.