File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes exclusive row level lock in MySql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "exclusive row level lock in MySql" Watch "exclusive row level lock in MySql" New topic
Author

exclusive row level lock in MySql

muthu muruges
Ranch Hand

Joined: Feb 28, 2003
Posts: 70
how to create exlusive row level lock in mySQL database (db version 4.0 and database type is InnoDB). Please explain me thru' sql syntax.
sandesh bangera
Greenhorn

Joined: Nov 13, 2002
Posts: 12
Well in oracle, you would enter something like

sql> Select <columns> from <table> where <condition> FOR UPDATE;

This puts a Exclusive lock on the selected rows that will be release by either a commit / rollback;

If you fail to provide a where condition then the entire table is locked.
muthu muruges
Ranch Hand

Joined: Feb 28, 2003
Posts: 70
what about in MySQL?,

I would like the locking query should work for the following scenario,
1) Having one DB connection
2) lock some rows by one thread
3) using the same connection lock some other rows by the second thread
4) release the lock aquired by the first thread, during this lock relase the second lock should not get relased
5) release the lock aquired by the second thread

is there any row level readlock or writelock exist in MySQL?
muthu muruges
Ranch Hand

Joined: Feb 28, 2003
Posts: 70
any updates please.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30075
    
149

Muthu,
According to the documentation, you get table level locking by default.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
 
subject: exclusive row level lock in MySql
 
Similar Threads
Problems with locking when loading
Row level lock help
date insert autometically in to DB at the time of submitting form
How to keep database safe from multiple operations?
Strange transcation question