what is the difference when
1.a web application uses a direct JDBC connection to interact with the RDBMS.
2.a web applciation uses a datasource functionality provided by the application server to interact with the RDBMS.
Please let me know the advantages and the disadvantages.
If you have DataSource setup, you can Use Server's JNDI service to access DataSource object which gives you flexibility in connecting with different database without changing anything in application or in WAR.
Suppose you have three kind of Environment (Dev,QA, Prod) each of them should connect to separate databases. If you have used DataSource setup along with JNDI name. You just need to call JNDL name in you application and server at each environment with connect with appropriate database. Assuming each server has their own DataSource configured.