Advantages of DataSource Objects
by, 03-10-2012 at 08:56 AM (1846 Views)
A DataSource object is considered a good alternative of class “DriverManager” and is most preferable to be used as it creates a database connection. There is no need to hard code the JDBC URL or driver name in application while using DataSource object. Such approach is loosely coupled & more portable.
When there is a need to do alterations then changes might be done in properties file by the admin and no code changes of ever application is needed, which is involved in its implementation.
Other than ease of maintenance and portability, DataSource object usage also offers many other advantages.
When DataSource interface gets implemented to do work along with implementation ConnectionPoolDataSource, connection produced will be pooled connections. Likewise, when it works with XADataSource then connections produced will be those that are usable in distributed transactions.