Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How works DataSource

I wondered how works method getConnection() at DataSource? I assume that DataSource calling DriverManager.getConnection every time when we call DataSource.getConnection with our properties that we setting in DataSource. Is that true?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The answers to your question can be deduced from the DataSource javadoc.

"The DataSource interface is implemented by a driver vendor. There are three types of implementations:

  • Basic implementation — produces a standard Connection object
  • Connection pooling implementation — produces a Connection object that will automatically participate in connection pooling. This
    implementation works with a middle-tier connection pooling manager.
  • Distributed transaction implementation — produces a Connection object that may be used for distributed transactions and almost always
    participates in connection pooling. This implementation works with a
    middle-tier transaction manager and almost always with a connection
    pooling manager.
    "

Thus:

I wondered how works method getConnection() at DataSource?

It is vendor specific, and depends on the type of implementation that the vendor provides.

I assume that DataSource calling DriverManager.getConnection every time when we call DataSource.getConnection with our properties that we setting in DataSource. Is that true?

Not necessarily. For example, getConnection() could return the same Connection object each time it is called.

If you want to know how a specific DataSource works, you would need to look at its documentation … or alternatively its source code.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading