• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

data source and connection pooling ?

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic