On 6/27/2016 1:07 AM, Jerry Malcolm wrote:
On 6/26/2016 8:27 PM, David Kerber wrote:
On 6/26/2016 1:32 AM, Jerry Malcolm wrote:
I have a webapp that runs on a single host. It has one primary
database. But it has many secondary databases. There is one
secondary database for each of my clients that use my app. These
client databases come and go regularly as clients signup and leave.
I don't want to have to edit Tomcat conf files adding and deleting
<Resource> tags for the secondary databases and then have to bounce
Tomcat several times a day as clients come onboard or leave.
I have one <Resource> tag for the primary database. The id/pw and
everything else in the resource tag is the same for all of the
databases. Is there a way to specify/override the url (i.e. the
database name) at runtime to connect to whatever secondary database I
need for the particular client? Or is there a way to clone a
datasource for a different url/database? I still would like to use
the one resource tag in the context.xml.default conf file to specify
the id/pw for the secondary DBs. I'd prefer not to hardcode id/pw in
the java code. But if that is the only option, I can do it.
Hopefully there is some way to dynamically select the db in a
datasource at runtime... (??) Suggestions?
You can move your authentication code into your application, rather
than having TC handle it. Then you can pick any database or data
source you want.
I know I can hardcode the connection in the code. But that is not
going to provide connection pooling. That 's a huge performance hit.
I really want the same capability I get with jdbc datasources, only
without hardcoding hundreds of them in the conf files.
You would need to handle your own pooling (which isn't particularly
difficult), but there's certainly no need to hard-code anything. All of
your db connection info can be in a "master" database, in Tomcat's
configurations, or anywhere else that is accessible by your code. If
you can build connection strings from login information, it would be
super simple.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org