Connectiondoes not setup a database connection as it might seem, instead it sets up a connection pool. If you are interested in a real database connection, you should use
QueryRunner. Each instance of
QueryRunneris a separate isolated database connection. Using query runners you can control your queries to execute using single database connection and manually control your database transaction.
QueryRunneryou should first create a connection pool, in any of the ways described on the
Connectiondocumentation. Once a connection has established, use the
createQueryRunnerfunction to create an isolated connection.
createQueryRunnerCreates a query runner used to perform queries on a single database connection.
QueryRunneruse connect to activate the connection.
QueryRunneris used to manage an isolated database connection, make sure to release it when it is not needed anymore to make it available to the connection pool again. After connection is released it is not possible to use the query runner methods.