Sie sind auf Seite 1von 1

Source : http://docs.oracle.com/javase/tutorial/jdbc/basics/sqldatasources.

html
Advantages of DataSource Objects
Because of its properties, a DataSource object is a better alternative t
han the DriverManager class for getting a connection. Programmers no longer have
to hard code the driver name or JDBC URL in their applications, which makes the
m more portable. Also, DataSource properties make maintaining code much simpler.
If there is a change, the system administrator can update data source propertie
s and not be concerned about changing every application that makes a connection
to the data source. For example, if the data source were moved to a different se
rver, all the system administrator would have to do is set the serverName proper
ty to the new server name.
Aside from portability and ease of maintenance, using a DataSource objec
t to get connections can offer other advantages. When the DataSource interface i
s implemented to work with a ConnectionPoolDataSource implementation, all of the
connections produced by instances of that DataSource class will automatically b
e pooled connections. Similarly, when the DataSource implementation is implement
ed to work with an XADataSource class, all of the connections it produces will a
utomatically be connections that can be used in a distributed transaction.
* If we are using datasource within the server we can share(By using JNDI) this
datasource to amoung the application that are running in the same server.
*

Das könnte Ihnen auch gefallen