aspose file tools*
The moose likes JDBC 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

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
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
internet detective

Joined: May 26, 2003
Posts: 29287

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.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 383

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
Similar Threads
scea - 1 experiences
Is Ruby easier to learn than Java, since there appears to be less code to write?
Passed SCBCD 5.0
Problem with Devakas Final Exam Q on Static Thread methods
WA #1.....word association