前2天看了一点关于数据库并发控制方面的理论,介绍得很详细(基于锁/时间戳/有效性的协议),但是我有一个问题一直搞不清楚。就是,在应用程序中,对于并发控制要做哪些工作?难道每个应用程序都要实现自己的并发控制器么?哪位兄弟有这方面的经验,或者资料,给介绍下吧。
十分感谢!!!

解决方案 »

  1.   

    我的意思是说,在进行数据库更新操作的时候,锁是怎么管理的?
    比如说更新一个表时,这个表就需要被锁定,那么这个加锁操作是在哪里执行的(持久层使用JDBC实现)?多个事务更新同一个表的时候,锁的管理在哪里进行?每个应用程序都要实现一个锁管理器么??
      

  2.   

    是不是在update语句前面 把要更新的行加上锁select ... for update
    等到这个事务完成的时候 将锁撤销对于这方面 我也不很明了 关注
      

  3.   

    还是我自己来回答吧:How Oracle Locks Data
    Locks are mechanisms that prevent destructive interaction between transactions accessing the same resource?either user objects such as tables and rows or system objects not visible to users, such as shared data structures in memory and data dictionary rows.In all cases, Oracle automatically obtains necessary locks when executing SQL statements, so users need not be concerned with such details. Oracle automatically uses the lowest applicable level of restrictiveness to provide the highest degree of data concurrency yet also provide fail-safe data integrity. Oracle also allows the user to lock data manually.
    Transactions and Data Concurrency
    Oracle provides data concurrency and integrity between transactions using its locking mechanisms. Because the locking mechanisms of Oracle are tied closely to transaction control, application designers need only define transactions properly, and Oracle automatically manages locking.Keep in mind that Oracle locking is fully automatic and requires no user action. Implicit locking occurs for all SQL statements so that database users never need to lock any resource explicitly. Oracle's default locking mechanisms lock data at the lowest level of restrictiveness to guarantee data integrity while allowing the highest degree of data concurrency.
    上述资料来源于Oracle在线文档:
    http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14220/consist.htm#i5704
    ^_^
      

  4.   

    http://book.csdn.net/bookfiles/82/
    比较经典的文章,特别是乐观锁和悲观锁的说明