
Create a Database Connection by Passing a DataSource Object
If the DataSource object is not null, a connection is picked up from the connection pool of the datasource. Else, direct connection to the database is created by DriverManager. import javax.sql.DataSource;import java.sql.Connection;import java.sql.DriverManager;public Connection getConnection(DataSource dataSource) { String url = “Your_database_url”; String driver = “Your_database_driver”; String username = “Your_database_user”; String