Search code examples
javaglassfishdatasourcejtds

DataSource getConnection new connection or existing connection


Does DataSource getConnection() method return a new Connection for each call or can it return an existing connection that's open by the same thread? Is this implementation dependent?

I am on glassfish 3.1 and using the jtds driver. Thanks.


Solution

  • Looking at the source code for jtds driver, it seems to create a new connection object for each call of getConnection().

    If you look further down into the driver.connect(url, props) call, it creates a new connection object using the driver (in the connect() method of the driver).