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 EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "difference between Driver Manager and Data Source " Watch "difference between Driver Manager and Data Source " New topic
Author

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.....

Thanks

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

Joined: May 26, 2003
Posts: 29233
    
138

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

regards,
Lucky


http://plainoldjavaobject.blogspot.in
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 http://commons.apache.org/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: http://aspose.com/file-tools
 
subject: difference between Driver Manager and Data Source
 
Similar Threads
Problem with Devakas Final Exam Q on Static Thread methods
scea - 1 experiences
Is Ruby easier to learn than Java, since there appears to be less code to write?
Passed SCBCD 5.0
WA #1.....word association