我正在开发一个基于数据库的网络应用程序。 在我的应用程序中,我从两个不同的 Servlet 访问此服务,并且这些访问可能是并发的。
我需要知道是否允许,如果不允许,我该怎么做? 是否有一些技巧可以以线程安全的方式执行查询?
最佳答案
这是可能的,并且如何处理将是基于数据库设置(隔离级别设置)的数据库责任。
以下是 SQL Server 中的隔离级别这些可能会因数据库而异。
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)
关于java - 是否可以从两个不同的 Servlet 同时访问同一个数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12098729/