Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Standalone Connection pooling with DBCP

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ranchers,

I'm trying to create a db connection pooling for standalone application using DBCP but I'm not sure if it is possible for DBCP to have different connection pool.

I have successfully created a single pool (i.e. 1 datasource for 1 pool) but I need to create different pool since I will be connecting to different database. I need to connect to this database real time since the database names will be based on generated date and user criteria.

Does DBCP has pool manager where it manages several connection pool or do I have to create a singleton class to manage several pool of connections?

Thanks.
 
Bartender
Posts: 2660
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
DBCP allows you to create several connection pools, but yes, you have to manage access to these pools yourself.
In their standalone example, the DBCP team suggests that you use JNDI.

Regards, Jan
 
Mona Tajik
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jan for the info.
 
Mona Tajik
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is another example to use DBCP pooling for standalone application DBCP Datasource.

One can also just redirect connection to database (i.e. dbname.tablename) when accessing data so you need not create another connection for different database.
 
Jan Cumps
Bartender
Posts: 2660
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

One can also just redirect connection to database (i.e. dbname.tablename) when accessing data so you need not create another connection for different database

.
Yes, if they are accessible from the same database instance, and with the same user account.
I did not understand that this was your goal.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic