[英]Is it possible to access concurrently to the same DB from two different Servlets?
I'm developing a web application, based on a DB. 我正在开发一个基于数据库的Web应用程序。 In my application, I access to this one from two different Servlets, and it's possible these accesses are concurrently.
在我的应用程序中,我从两个不同的Servlet访问这个,并且这些访问可能是同时进行的。
I need to know if it is permitted, and if not, how can I do it? 我需要知道是否允许,如果没有,我该怎么办? Is there some trick to perform queries in a thread-safe way?
是否有一些技巧以线程安全的方式执行查询?
It is possible and how to handle will be database responsibility based on DB settings (isolation level settings). 有可能并且如何处理将基于数据库设置(隔离级别设置)的数据库责任。
Here are the isolation levels in SQL Server and these may vary based on DB. 以下是SQL Server中的隔离级别,这些级别可能因DB而异。
1.Read uncommitted (the lowest level where transactions are isolated only enough to ensure that physically corrupt data is not read)
2.Read committed (Database Engine default level)
3.Repeatable read
4.Serializable (the highest level, where transactions are completely isolated from one another)
One of the primary design requirements for databases is concurrent access. 数据库的主要设计要求之一是并发访问。 Fact is, you are most probably already doing it in any one of your servlets since they can serve several requests in parallel, usng multiple db connections.
事实上,您很可能已经在任何一个 servlet中执行它,因为它们可以并行处理多个请求,使用多个数据库连接。 Using two connections from one app is (almost) exactly the same thing as using two connections from two apps.
使用来自一个应用程序的两个连接(几乎)与使用来自两个应用程序的两个连接完全相同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.