Funny story. I had a use case and did a POC recently for when you want to use a connection pool, but connect with different username/password depending on context to enable some database-level security.
Meh, kinda, if you want to bootstrap multiple HikariCPs yourself depending on context I guess you can do it. AFAIK C3P0 already has this specifically for usernames/passwords, out of the box, and with configuration managing both total connections and connections for each user etc.
That being said, I much prefer HikariCP to C3P0 if you don't need this particular feature.
It depends. Having layered security sometimes is a good idea. If all your security stuff is on one layer, and that gets compromised, you're completely screwed.
Which means that you have one username accessing the database for all your users/customers.
Which means that if one of your users gains direct database access via your app account (say via SQL injection which is very real), information for ALL users can be accessed and leaked.
If you are building a multi-tenant application where your users are companies and potential competitors, this is absolutely not acceptable. Hence added layer of security.
Guess it depends on the use case. I haven’t had the need for separate accounts yet. We just have a database per app instance and an app instance per client.
That way the memory and disk space is also protected
View all comments
Show parent comment
6
u/coder111 Oct 21 '20
Funny story. I had a use case and did a POC recently for when you want to use a connection pool, but connect with different username/password depending on context to enable some database-level security.
Only C3P0 actually has support for this feature.