File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes how to set connection size (dbcp) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "how to set connection size (dbcp)" Watch "how to set connection size (dbcp)" New topic
Author

how to set connection size (dbcp)

Robert Kennedy
Ranch Hand

Joined: Jun 27, 2008
Posts: 63
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,
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3652

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.


My Blog: Down Home Country Coding with Scott Selikoff
Robert Kennedy
Ranch Hand

Joined: Jun 27, 2008
Posts: 63
Thank you for your response. What I require is a mean to set the connection size (initialSize) using Java directly, not a configuration document.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2343

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


OCUP UML fundamental
ITIL foundation
Scott Selikoff
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3652

Usually you leave managing the connection pol to the server, not the application code.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel
 
subject: how to set connection size (dbcp)
 
Similar Threads
Tomcat DBCP: Problem with first update statement after Tomcat restart
DBCP initialSize param problem
What are db configuration parameters like initialsize,max active?
connpool_max_limit help
JDBC connection pool