public class NameLocker extends Object implements AutoCloseable
Constructor and Description |
---|
NameLocker(Connection connection,
String lockName)
Get a named lock.
|
NameLocker(Connection connection,
String lockName,
int timeout)
Get a named lock.
|
public NameLocker(Connection connection, String lockName) throws SQLException, CannotObtainLockException, AlreadyLockedException
This method does not wait for a timeout when getting a lock.
connection
- MySQL connectionlockName
- Name of lockSQLException
- SQL is something wrongCannotObtainLockException
- Cannot obtain a lock by something error of MySQLAlreadyLockedException
- A lock has already taken by other clientpublic NameLocker(Connection connection, String lockName, int timeout) throws SQLException, CannotObtainLockException, AlreadyLockedException
connection
- MySQL connectionlockName
- Name of locktimeout
- Seconds for timeoutSQLException
- SQL is something wrongCannotObtainLockException
- Cannot obtain a lock by something error of MySQLAlreadyLockedException
- A lock has already taken by other clientpublic void close() throws Exception
close
in interface AutoCloseable
Exception
Copyright © 2014. All rights reserved.