linus
linus

Reputation: 75

is this approach correct for connection management in orient DB?

I am using OrientGraphFactory to manage pool of connection

OrientGraphFactory graphFactory = new OrientGraphFactory(url,username,password).setupPool(DEFAULT_MIN_POOL_SIZE, maxPoolSize);

and i have a function which checks the active connection on thread and returns it

 public OrientGraph openDatabase() {
    OrientGraph db  = (OrientGraph)OrientGraph.getActiveGraph();
    if(db==null || db.isClosed())
    {
        db = graphFactory.getTx();
    }
    return db ;
 }

in my functions do i have to close/shutdown connection after use or it will be shutdown after the thread is terminated.

Upvotes: 1

Views: 137

Answers (1)

Andrey Lomakin
Andrey Lomakin

Reputation: 656

This approach is incorrect because you use internal API. More simple version db = graphFactory.getTx(); takes in account all check which you done above.

Upvotes: 2

Related Questions