How to use connections with Stardog

Hi everyone,

I have a few doubts about how to use connections with Stardog:

  • When obtaining a connection from the ConnectionPool, after using it, should close and release it, or just release it? I would expect that connectionPool.release(connection) would do the close for me.

  • Can we reuse the same connection over and over (even with concurrent requests) if we are only selecting data and not applying a transaction/mutation?

Thanks a lot.

I believe that you should release the connection back to the pool but don't close it. The purpose of the connection pool is to avoid the cost of opening the connection. I don't think you'd get an error when you closed the connection but the next person to use it would get and error that the connection was closed.

See the documentation on connection pooling

I think you could reuse the same connection over and over but you'd find yourself reimplementing a connection pool to do it right which would be silly since you already have one but if there's something special you need to do that the built in one isn't doing then go for it.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.