Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a datasource in java? Can someone please explain me in simple language?

What is a DataSource in java? Can someone please explain me in simple language?

like image 733
Shubham Arya Avatar asked Nov 07 '22 23:11

Shubham Arya


2 Answers

DataSource implementation classes allow you to use connection pool and loose coupling for connectivity.

  1. Most of the times we are looking for loose coupling for connectivity so that we can switch databases easily.

  2. Creating connections can be heavy process and it is not a good idea to let every part of program create its own connections which can lead to resource starvation and slow performance. that's why we use connection pooling. most database drivers provide datasource implementation classes that can be used in connection pool.

like image 171
Shubh Sharma Avatar answered Nov 14 '22 21:11

Shubh Sharma


Data Source is explained very well here. Please go through the link Data Source in Java

like image 32
Pooja Arora Avatar answered Nov 14 '22 20:11

Pooja Arora