views:

291

answers:

4

We have a web application right now that we deploy a copy for each client. Our current deployment strategy is to create a uniquely named jdbc connection pool for each instance. so say jdbc/client. They are specified like this...

< Context path="/"
        reloadable="true"
        docBase="\home\client\ROOT"
        debug="5" >
        < Resource name="jdbc/client"
                auth="Container"
                type="javax.sql.DataSource"
                maxActive="100"
                maxIdle="30"
                validationQuery="SELECT 1"
                testWhileIdle="true"
                timeBetweenEvictionRunsMillis="300000"
                numTestsPerEvictionRun="6"
                minEvictableIdleTimeMillis="1800000"
                maxWait="10000"
                username="user"
                password="pass"
                driverClassName="com.mysql.jdbc.Driver"
                url="jdbc:mysql://databaseserver:3306/client ?zeroDateTimeBehavior=convertToNull&amp;jdbcCompliantTruncation=false"/>
< /Context>

The question is, if I were to standardize it so that instead of unique names the connection pool is called jdbc/database on all deployed instances, is there a chance of database crossing, ie one customer in another customer's database, or are these localized to a specific deployed instance?

Thoughts? Thanks, Scott

+3  A: 

No. The scope of the data source name is one Tomcat instance.

If you are starting a separate Tomcat process for each customer, all that matters is how the data source is configured, not what Tomcat calls it. As long as each data source is configured to use a different database, there won't be any cross talk.

erickson
A: 

If you're defining the JNDI DataSource resource within the Context for a deployment of the application, I believe you could even have multiple copies of the same application running in the same Tomcat instance and using the same JNDI name to access different databases. If each application instance is running in a different instance of Tomcat completely, there is certainly no way that one instance would be referring to the database specified for another instance.

ColinD
A: 

This depends on how you deploy application for each client,

  1. If each client gets their own Tomcat installation (they have different CATALINA_HOME), there is no chance for it to cross.
  2. If they all use the same installation but run as different host in Tomcat, you need to make sure you don't define the datasource in conf/context.xml, which is shared by all hosts.
  3. If all clients share the same Tomcat instances and they are simply different web apps, more attention is required. You need to define the datasource either in META-INF/context.xml or WEB-INF/web.xml. For further isolation, you should copy dbcp.jar to WEB-INF/lib of each application so they use their own DBCP instance.
ZZ Coder
A: 

No there is no chance of database crossing becoz the scope of the data source name is one Tomcat instance and you can have multiple data source in single tomcat instance .... so as long as data source is different there is no chance of database crossing.....