tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anthony Biacco <abia...@handll.com>
Subject Re: Runtime Cloning of DataSource for Different DB?
Date Mon, 27 Jun 2016 12:26:43 GMT
On Sun, Jun 26, 2016 at 11:07 PM, Jerry Malcolm <techstuff@malcolms.com>
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.
>
>
I seem to recall DBCP having a per-user pool data source feature, where you
can pass different credentials to the same base Resource. Whether you can
change the database too, i don't remember.
You might want to check the docs or ask those guys a couple doors down.

-Tony





> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message