다음 코드를 살펴보십시오. 1. stardog에 연결 풀을 생성 중입니다.
2. 풀에서 연결 얻기. 3. 사용 후 풀에 연결을 되 돌리십시오.stardog의 연결 풀에서 연결을 닫으면 어떻게됩니까
풀로 돌아가는 대신 aConn.close()
을하면 내 질문은 어떻게됩니까? 내가 aConn.close();
가 추천 주요 내가 어떤 클래스에서 연결을 사용할 때마다 내가 해달라고 이유는 내가 aPool.release(aConn);
을 할 수있는 풀 객체를 해달라고인가하여 연결을 닫으면 happends 것을
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();
그래. 풀링 사용을 망칠 수 있습니까?
감사합니다. 이것은 명확한 아이디어를 제공합니다. –
다른 사람들이 이것이 올바른 정보라는 것을 알고 있도록 답변을 수락하십시오. – Michael
닫힌 연결을 유지하는 풀은 다른 문제를 생성합니까? 다른 클래스가 연결을 요청하면 풀은 닫힌 연결을 제공하고 닫힌 연결 예외로 끝납니다. –