Hi, I am using the JDBC Driver, should we create a new connection every time the webpage is called? or can we maintain one connection and have all the requests to the database use that one connection?
@karansoi Creating a connection is relatively expensive, but it’s also not
safe to share a jdbc connection between multiple threads. There are a
number of libraries for “jdbs connection pooling” that you might consider
to help with this. I haven’t used any of them personally (maybe one of my
colleagues has and will chime in) but c3p0 (https://github.com/swaldman/c3p0)
and HikariCP (https://github.com/brettwooldridge/HikariCP) are two options.
Thanks a ton for your quick reply. Will try one of those connection pooling libraries. though wished it worked more like Cassandra’s Connections, ‘they are thread aware’.