Take a look at the following code.
1. I am creating a connection pool to stardog
2. Obtaining a connection from the pool.
3. Returning the connection to pool after the use.
My question is what will happen if I do aConn.close()
instead of returning to the pool.
ConnectionConfiguration aConnConfig = ConnectionConfiguration
.to("testConnectionPool")
.credentials("admin", "admin");
ConnectionPoolConfig aConfig = ConnectionPoolConfig
.using(aConnConfig)
.minPool(10)
.maxPool(1000)
.expiration(1, TimeUnit.HOURS)
.blockAtCapacity(1, TimeUnit.MINUTES);
// now i can create my actual connection pool
ConnectionPool aPool = aConfig.create();
// if I want a connection object...
Connection aConn = aPool.obtain();
// now I can feel free to use the connection object as usual...
// and when I'm done with it, instead of closing the connection,
//I want to return it to the pool instead.
aPool.release(aConn);
// and when I'm done with the pool, shut it down!
aPool.shutdown();
what happends if I close the connection by aConn.close();
The main reason I am asking whenever I use connection in any classes I dont have the pool object to do aPool.release(aConn);
Is it recommended to do . Will it spoil the use of pooling.