File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes difference between Driver Manager and Data Source Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "difference between Driver Manager and Data Source " Watch "difference between Driver Manager and Data Source " New topic

difference between Driver Manager and Data Source

Inder Kumar Rathore
Ranch Hand

Joined: Apr 14, 2010
Posts: 41

how to use these two in the program.......
i read java tutorial but could not understand.....


Living is easy with your eyes closed.....
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32823

A DataSource is an externally managed connection - usually used with a connection pool. A Driver Manager creats the connection directly in code for one time use.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 384

a data source is one where you get your entries from usually a database

a DataManager is an interface in java JDBC that provides you with the comfort of creating connections to that data source

Prashant Hurria
Ranch Hand

Joined: Mar 23, 2009
Posts: 40
You create a JDBC Connection using Driver manager by using something like the following code

now this operation is expesive so you might want to implement a factory which creates a conection pool.
Also you might not want to right the boiler plate code again and again so dtasource to the rescue ....
Use a Project like apache DBCP
create an instance of org.apache.commons.dbcp.BasicDataSource class supply it with the Driver Name,Username ,Password ,URL
Simply get the connection by calling a getter no boiler plate code needed.

I agree. Here's the link:
subject: difference between Driver Manager and Data Source
It's not a secret anymore!