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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:06:01+00:00 2026-06-17T22:06:01+00:00

HINT : My hosting tomcat system provides only 20 db connections My working project

  • 0

HINT : My hosting tomcat system provides only 20 db connections

My working project in localhsot

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
          p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
          p:username="${jdbc.username}" p:password="${jdbc.password}" />

This worked good in localhost, but in production it run for a while and Exception : “user has allready max no of connection”.

After many google

I used c3p0

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

This worked in localhost, but same problem in production server

Hint: I think some config in c3p0 can solve this. Please help me with you suggestion (My hosting provides only 20 connections)

Also i tried tomcat

<bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSourceFactory">
        <property name="driverClassName" value="${jdbc.driverClassName}" />
        <property name="url" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <property name="maxActive" value="20"/>
    </bean>

The above tomcat code is wrong and will not work – because wrong property (I know that). How to set this for my production use(only 20 connections)

If you know how to use tomcat pool please help us.

I also used bonecp

<bean id="dataSource" class="com.jolbox.bonecp.BoneCPDataSource" destroy-method="close" >
        <property name="driverClass" value="${jdbc.driverClassName}" />
        <property name="jdbcUrl" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <property name="idleConnectionTestPeriod" value="60"/>
        <property name="idleMaxAge" value="240"/>
        <property name="maxConnectionsPerPartition" value="10"/>
        <property name="minConnectionsPerPartition" value="5"/>
        <property name="partitionCount" value="1"/>
        <property name="acquireIncrement" value="5"/>
        <property name="statementsCacheSize" value="1000"/>
        <property name="releaseHelperThreads" value="3"/>
    </bean>

This worked in localhost but same problem in production “user has to many connections”.

I also tried apache-dbcp

As per tomcat 7 documentation – dbcp is no longer and tomcat will be bundled with pool. Even though i used dbcp and i cannot run my program. (I added only one jar and error was some class not found during project run)

As per my own idea :

I think above mentioned settings will be problem. Please help me with your suggestions. I’m not using hibernate up to now because of heavy weight. If hibernate can solve this problem please let us know.


EDITED

Currently I’m using this code. Is this code correct to my use(20 connection)

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"
      p:driverClass="${jdbc.driverClassName}" p:jdbcUrl="${jdbc.url}"
      p:user="${jdbc.username}" p:password="${jdbc.password}"

      p:acquireIncrement="1" 
      p:checkoutTimeout="1"
      p:idleConnectionTestPeriod="5"           
      p:maxIdleTime="5" 
      p:maxIdleTimeExcessConnections="1" 
      p:maxPoolSize="20" p:maxStatements="0" p:maxStatementsPerConnection="0" 
      p:minPoolSize="1" 
      p:numHelperThreads="100"
      p:overrideDefaultUser="${jdbc.username}" p:overrideDefaultPassword="${jdbc.password}"
      p:propertyCycle="3" 
      p:testConnectionOnCheckin="true"
      p:unreturnedConnectionTimeout="5" />

DAO code :

@Repository
public class TutorialsDAOImpl implements TutorialsDAO {
//---
private JdbcTemplate jdbcTemplate;
    private DataSource dataSource;

    @Autowired
    public void setDataSource(DataSource dataSource) {
        this.jdbcTemplate = new JdbcTemplate(dataSource);
    }
//---
@Override
    public List<TutorialsCategory_vo> getTutorialsCategory() {
        sql = "SELECT * FROM `tutorials_category` ORDER BY `slug` ASC;";
        List<TutorialsCategory_vo> vo = null;
        try {
            vo = this.jdbcTemplate.query(sql, new Object[]{}, tutorialsCategory_mapper);
        } catch (Exception e) {
            log.log(Level.SEVERE, null, e);
        }
        return vo;
    }

These are the codes i’m using. If there is any error/corrections pls correct me.


Edited (for Arun P Johny ‘s question)

My current project url.

I updated my current code above.


  • 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-17T22:06:02+00:00Added an answer on June 17, 2026 at 10:06 pm

    This is my final c3p0 settings:

    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"
              p:driverClass="${jdbc.driverClassName}" p:jdbcUrl="${jdbc.url}"
              p:user="${jdbc.username}" p:password="${jdbc.password}"
    
              p:acquireIncrement="1" 
              p:checkoutTimeout="3000"
              p:idleConnectionTestPeriod="5"           
              p:maxIdleTime="3" 
              p:maxIdleTimeExcessConnections="1" 
              p:maxPoolSize="20" p:maxStatements="20000" p:maxStatementsPerConnection="1000" 
              p:minPoolSize="1" 
              p:numHelperThreads="1000"
              p:overrideDefaultUser="${jdbc.username}" p:overrideDefaultPassword="${jdbc.password}"
              p:propertyCycle="3" 
              p:statementCacheNumDeferredCloseThreads="1"
              p:testConnectionOnCheckin="true"
              p:unreturnedConnectionTimeout="7" />
    

    This works fine, but taking more time(1 or 2 secounds – not more than 3 secounds).

    I also checked this code by shutting down mysql. My program waited up to, i start mysql. This is good. This code waits for all db connections to complete and out put correctly.

    Can we make this settings even faster? Hint: my server provides only 20 connections.

    If you provide a correct answer i’ll make it as right answer, after checking.

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

Sidebar

Related Questions

The hint for extension methods on a normal class file and the one shown
Can someone give a hint how does compiler process expressions such as class DerivedA:
my jquery hint only works if in an textbox and not a a textarea.
I got a hint from someone today that my curl_multi() code is actually working
The focus visual hint that wpf provides on Windows 7 is a dashed line,
Does anybody has a hint for the following problem? I have a derived class
I'm designing help/hint system for my webpage, I'd like to incoroporate jQuery based contextual
Can function argument have hint in cfscript (CF9)? CFML style: <cffunction name=myFunc output=false returntype=void>
I would like a hint or much better a solution for this: I do
I'd like a hint on how to apply this function: dti xs = (map

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.