Tomcat JDBC 连接池是否在实例之间共享?
我们现在有一个 Web 应用程序,我们为每个客户端部署一个副本。我们当前的部署策略是为每个实例创建一个唯一命名的jdbc连接池。 所以说 jdbc/client。它们是这样指定的...
< 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&jdbcCompliantTruncation=false"/>
< /Context>
问题是,如果我要标准化它,以便连接池在所有部署的实例上都称为 jdbc/database 而不是唯一的名称,是否有可能发生数据库交叉,即一个客户在另一个客户中客户的数据库,或者这些数据库是否本地化到特定的部署实例?
想法? 谢谢, 斯科特
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&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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不可以,数据源名称的范围是1个Tomcat实例。
如果您为每个客户启动单独的 Tomcat 进程,那么重要的是数据源的配置方式,而不是 Tomcat 对其的称呼。只要将每个数据源配置为使用不同的数据库,就不会有任何串扰。
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.
这取决于您如何为每个客户端部署应用程序,
This depends on how you deploy application for each client,
如果您在上下文中定义 JNDI
DataSource
资源来部署应用程序,我相信您甚至可以在同一个 Tomcat 实例中运行同一应用程序的多个副本,并使用相同的 JNDI 名称访问不同的数据库。如果每个应用程序实例完全在不同的 Tomcat 实例中运行,则一个实例肯定无法引用为另一实例指定的数据库。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.不,不存在数据库交叉的可能性,因为数据源名称的范围是一个 Tomcat 实例,并且您可以在单个 tomcat 实例中拥有多个数据源....因此,只要数据源不同,就不可能存在数据库交叉……
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.....