Search code examples
database-connectioncassandrahector

How do I close a connection to a Cassandra cluster in the Hector API?


It may sound like a dumb question, but I actually looked that up and couldn't find anything on it. I know that it is good practice to close database connections so you don't accidentally bog your database down with unclosed connections. However, there doesn't appear to be any Hector API function to "close" a connection.

It's entirely possible that Cassandra databases take commands rather than connections.


Solution

  • Hector manages the connection pool for you. You do not need to "close" a connection.

    Hector by default opens up 1/3rd of maxActive connections (by default 50). This allows Hector to respond fast and not waste time opening connections when an operation comes in. This is especially useful for web containers who "stand hot" waiting for requests.

    The connections are closed when the JVM shuts down.