Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

difference between Driver Manager and Data Source

 
Inder Kumar Rathore
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

how to use these two in the program.......
i read java tutorial but could not understand.....
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 35977
422
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Lalit Mehra
Ranch Hand
Posts: 384
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Prashant Hurria
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.




 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!