Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How does using DataSource make Code more portable ?

 
Vishal Saxena
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
Without it too, the driver/db info. can be read from a file - it need not be hard coded in the class.
With it too - the DataSource properties will be read from a file to bind it, the jndi info will again be read from a file for lookup.
regards,
 
Jacob George
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vishal Saxena:
hello,
Without it too, the driver/db info. can be read from a file - it need not be hard coded in the class.
With it too - the DataSource properties will be read from a file to bind it, the jndi info will again be read from a file for lookup.
regards,

Hi,
In a distributed environment, the datasource is created by a privilaged user (an admin) and all the clients look-up these datasource objects from a repository. So even-if the physical location of database server changes, only the datasource bound by admin needs modification; all the clients performing a look-up operation on this modified datasource will be working on this new information. So the client needn't be bothered of any changes on the URL, authentication details.
If the clients were using a normal Connection object, all the clients need to be updated on the changed information of DB server.
regards Jacob
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic