Links to data sources

I am reading about links vs datasources in Java and I have some questions. Is the data source just a manager and an abstraction of a connection (or multiple connections)?

+7
source share
4 answers

From docs :

A factory for connections to the physical data source that this DataSource object represents. An alternative to the DriverManager object is the DataSource object, the preferred way to get a connection.

In fact, DataSource is a Connection provider and has many implementations that work differently. For example:

  • The main implementation - creates a standard Connection object

  • Implementation of the connection pool - creates a Connection object that will automatically participate in the connection pool. This implementation works with the middleware connection pool manager.

  • Distributed Transaction Implementation - Creates a Connection object that can be used for distributed transactions and almost always participates in the connection pool. This implementation works with a mid-level transaction manager and almost always with a pool manager connection.

+9
source

A connection is a connection :) DataSource is a connection manager (connection pool).

+2
source

The data source is the source of your data, the connection is the driver.

-one
source

A DataSource is a poor concept in its existing form, as if it was intended for abstract interactions, it should not return any SQL connection that you need to interact with in the first place. Itโ€™s also overkill, and XA is a fantastic concept that some people pay dearly for lack of reliable implementation in the world (I mean that all commercial implementers of the enterprise simply fail and open up the business ... someone suffered from for this in finance, but I will not mention the names). In general, regardless of whether it recommends Sun or Oracle, this leads to over-development and some technical error in the code (taking into account contexts, additional steps to obtain data, some external configurations ... and, in the end, the supplierโ€™s implementation in any case). Some developed coroporate solutions that deal with consolidation, reconnecting etc are much better based on simple connections and DriverManager than the DataSource provided by DBMS vendors.

For the record, I worked with both, and I'm based on facts found in different places. And if in doubt, ask why you can see a simple JDBC URL in your Hibernate configuration throughout your business. Many just dump the heavyweigtt J2EE idea and become light ... also using simple DriverManager-based connections.

You want to get your career on the web, then go to XA DataSources and repair the failed transactions, where the poor implementation of XA is very successful.

-one
source

All Articles