Originally posted by Vishal Saxena:
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.
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.