• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

how to set connection size (dbcp)

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I am trying to control the number of initial connection when creating a connection pool (Apache-Postgres). I require 1-2 connections but i am initially receiving 4. I see that in BasicDataSource i can set the initialSize of the pool, however i do not understand how to set initialSize using PoolingDataSource.

Thanks,
 
author
Posts: 4356
45
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usually its in an XML file (or admin console) of where ever the pool is declared. BTW, why only 1-2? It seems like a pool that small is hardly worth putting in a pool.
 
Robert Kennedy
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your response. What I require is a mean to set the connection size (initialSize) using Java directly, not a configuration document.
 
Bartender
Posts: 2662
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Robert Kennedy:
Thank you for your response. What I require is a mean to set the connection size (initialSize) using Java directly, not a configuration document.




BasicDataSource allows you to create connection pool without xml config file. It has setters for the settings you would otherwise put in the config file.
BasicDataSource.setInitialSize(). Read the note in the javadoc: you have to call this method early.

Regards, Jan
 
Scott Selikoff
author
Posts: 4356
45
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Usually you leave managing the connection pol to the server, not the application code.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic