File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Table Locks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Table Locks" Watch "Table Locks" New topic

Table Locks

Gavin Tranter
Ranch Hand

Joined: Jan 01, 2007
Posts: 333
Hi all,
Not sure if this question is one I should be asking here, if not, I am sorry.

I am using mySQL (5.0.37) an am using a stored function to implement Oracle like sequence numbers.

I am having a little issue with the update.
So I was wondering if the use of BEGIN creates a lock on the table at the start of the stored function, so that while the function is executing no other function can update the sequence table.

I think this might be wishful thinking because it dosnt know what table I am trying to work with until it encounters the update

I will continue searching mySQL and if I find any answers will post them back here for the record.

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33129

This is the right place to ask your question.

I'm pretty sure you don't get a lock until the actual update statement. Also, note that some databases don't lock the whole table, just the row you are using. This probably isn't a problem for your table though.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Table Locks
It's not a secret anymore!