• 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

DriverManager vs DataSource

 
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the pros/cons for using DriverManager versus javax.sql.DataSource to obtain a JDBC connection ? I have
been using DriverManager method for quite a while now.
Thanks
Pho
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pho Tek:
What is the pros/cons for using DriverManager versus javax.sql.DataSource to obtain a JDBC connection ? I have
been using DriverManager method for quite a while now.

DriverManager is just that: a thin manager class for raw jdbc drivers. A DataSource is both more abstract and more powerful: it is a place where you get your database connections from. This means a couple of things. It means that a DataSource can usually be configured and managed by the application server instead of your application. It means that the connections you get from a DataSource can come from a connection pool for performance. It means that the connections may participate in a container-managed distributed transaction without you having to worry about the nitty gritty of it.
And even if your environment doesn't support DataSources, given that org.apache.struts.util.GenericDataSource can convert any old JDBC driver into a pooled DataSource I don't see why anyone would still want to use a DriverManager and a proprietary connection pool
- Peter
 
Pho Tek
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.
I had a look at the javadoc for GenericDataSource. It seems to have a serious limitation.


Generic data source implementation of the DataSource interface. WARNING - This implementation does not know how to provide connections with different username/password combinations..


Do you consider poolman a proprietary connection pooling framework ?
Pho
[This message has been edited by Pho Tek (edited November 08, 2001).]
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pho Tek:
I had a look at the javadoc for GenericDataSource. It seems to have a serious limitation.

True. For most web applications, this isn't a limitation. Unless I'm missing something, forcing each user to have his own database-level identity mostly defeats the purpose of having a connection pool anyway; in n-tier environments this is rarely done. Authentication and authorization is enforced in one of the middle tiers instead.
I don't know poolman, but I personally consider anything that doesn't expose a DataSource interface proprietary and obsolete.
- Peter
[This message has been edited by Peter den Haan (edited November 09, 2001).]
 
Pho Tek
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.codestudio.com/
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many thanks! That looks like an impressive piece of work. It's far more ambitious than Struts' GenericDataSource. And its DataSource can be bound in a JNDI tree too. If it's robust, go for it.
- Peter
 
Curse your sudden but inevitable betrayal! And this tiny ad too!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic