No, there's no good reason to have multiple DataSource instances if you only target a single database.
Multiple DataSource instances
-
14-07-2023 - |
Question
Is it less-than-ideal to have multiple DataSource
instances when using JDBC?
If I have a base class that has various subclasses that all use a single static instance of DataSource
(if it matters, I'm using the Postgres driver), I imagine that is ideal because there is a single source for them to get their connections and I'll see a bigger benefit from pooling connections.
The other option is to have each subclass have its own DataSource
instance, which I imagine is not ideal.
Just my guess though. Any more info would help!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow