Why we need datasource, we can directly use the connection pool instead of datasource
posted 11 years ago
Using a connection provided via datasource helps the developer get a transaction enabled Connection. Typically application servers have wrappers around the datasource which help them monitor the transactional lifecycle of the connection. Essentially these objects participate in the Java Transaction Service transactions.
Also defining a datasource helps maintain the connectivity details like username, password, JDBC URL and the database vendor independent of the application. Thus these can be easily changed without affecting the user application code.