aspose file tools*
The moose likes JDBC and the fly likes How does using DataSource make Code more portable ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How does using DataSource make Code more portable ?" Watch "How does using DataSource make Code more portable ?" New topic
Author

How does using DataSource make Code more portable ?

Vishal Saxena
Greenhorn

Joined: Apr 23, 2003
Posts: 26
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,


Thx -V
Jacob George
Ranch Hand

Joined: Jun 26, 2001
Posts: 46
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How does using DataSource make Code more portable ?