In the Java language, an DataSource object is an object that represents a data source entity. A data source is a tool for storing data, which can be a complex large-scale database or a file that is simply a row and column. The data source can be located on the server side or on the customer service side.
An application accesses a data source through a connection, then a DataSource object is the tool used to provide a connection to the data source. The DataSource interface provides two methods for establishing and connecting to a data source
Using the DataSource object to establish a connection to the database is more efficient than using the DriverManager interface, although both are similar in scope and provide a way to establish a connection to the database, set the maximum timeout time for the connection, get the stream, log in.
Introduction to Data sources: