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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:20:43+00:00 2026-06-12T13:20:43+00:00

I have been using Tomcat for a while. But I have never get myself

  • 0

I have been using Tomcat for a while. But I have never get myself fully educated about how it actually works, especially thread pooling and JDBC connection pooling.

Take a standard Spring web app (with c3p0 connection pool) for example. My questions are

  1. When TC starts up, does it create N threads, each with an
    applicationContext?

  2. If so, does it mean each thread will have its
    own list of bean instances created?

  3. One of the bean definition is

<bean id="dataSource" class = "com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
  <property name="driverClass" value="${db.driverClassName}"/>
  <property name="jdbcUrl" value="${db.url}"/>
  <property name="user" value="${db.username}"/>
  <property name="password" value="${db.password}"/>
  <property name="minPoolSize" value="5" />
</bean>

This will create 5 JDBC connections when this bean is created. Does it mean we are gonna end up with

5 connections x N threads = 5N connections?

This does not sound right to me. I thought the JDBC pool is shared across all threads. But apparently the JDBC pool (defined as a ComboPooledDataSource bean) is created as part of the applicationContext, right?

  • 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-12T13:20:44+00:00Added an answer on June 12, 2026 at 1:20 pm

    When TC starts up, does it create N threads, each with an applicationContext?

    No, it creates just one context with all the beans available for each and every thread within that web application. This means Spring beans (singleton by default) need to be thread safe since they are typically accessed concurrently by several threads. That’s fine because normally Spring beans are stateless and thus thread-safe by definition.

    Moreover there is only one JDBC connection pool holding 5 connections. All Tomcat web threads (and others, if created) compete for these 5 connections.

    Therefore your remaining questions are no longer relevant. What makes you think Spring creates contexts for every thread?

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

Sidebar

Related Questions

I have been using Tomcat for quite a while now but I am not
I've been using Tomcat for years, but I have been put on a new
I have been using echo $.sprintf(%01\$.2f,$numvar); for my USD formatting, but I only copied
I have been using Tomcat 7.0 and Eclipse Helios 3.6. I was asked to
I have been using tomcat for sometime and still can't find a good way
I've been using JSP/JSTL for a long time with Netbeans and Tomcat, but now
I have been using IntelliJ IDE (version 5.1) with Tomcat server (version 5.5) to
This following scippet works well, and I have been using it across many projects.
I have been thinking instead of using: Tomcat Apache Lightweight webserver PHP Ruby JSP
I have been using TortoiseSVN for some time and I really like it. I

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.