Factory Method pattern
Mybatis provides two javax.sql.DateSource interface for PooledDataSource and UnpooledDataSource, were created using PooledDataSourceFactory and UnpooledDataSourceFactory
UnpooledDataSource
Each UnpooledDataSource.getConnection()
will create a new link
PooledDataSource
PooledDataSource management PooledConnection object, PooledConnection encapsulates the true Connection object (created by UnpooledDataSource) and proxy object for the object (JDK dynamic proxy).
PooledConnection, invoke () will close () method to achieve a proxy to connect into the connection pool rather than a real turn off, poolState manage all the connected state