次のコードを見てください。1. stardog への接続プールを作成して
います。 2. プールから接続を取得しています。3. 使用後に接続をプールに戻す。
aConn.close()
私の質問は、プールに戻る代わりにそうするとどうなるかということです.
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();
接続を閉じるとどうなりますかaConn.close();
プールオブジェクトを持っていないクラスで接続を使用するたびに私が尋ねる主な理由aPool.release(aConn);
することをお勧めします。プーリングの使用を台無しにしますか。