Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

data source and connection pooling ?  RSS feed

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I have two questions here ---
I want to use some tool to configure database connection for some java web application.
1. what exactly does a "data source" mean ? It is not for a particular database, is it some logic name for various applications ? Can I let different web applications share a same "data source" ?
2. about connection pooling. After I specify the "data source", I am asked to specify the driver, url, and connection pooling. So, it seems this connection pooling option is ONLY for this data source. In other words, it is ONLY for the applications using this data source, is that right ? If I have some other application that access the same database but if they choose not to use connection pool, then these application do not have connection pooling feature EVEN they access the same database. Is that right ?
thanks.
 
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. A DataSource is simply a factory that maintains a "pool" of Connection objects. Creating Connection objects is a relatively expensive operation so maintaining a pool of Connection objects and reusing them for an application's database requests is more efficient. Refer to the J2EE Javadoc.
A datasource is usually used by J2EE applications and accessed thru JNDI. You would perform a JNDI lookup to use the datasource.
Yes, you should be able to allow multiple web applications use the same datasource but that is probably not a "Best Practice". I would probably create separate datasources.
2. Yes. Those applications that do not use a datasource will be required to create their own Connection objects instead of reusing those provided by the DataSource object.
[ January 14, 2004: Message edited by: Jay Damon ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!