# DbEnv.lock_get |

`

###

    import com.sleepycat.db.*;

    public DbLock lock_get(int locker,
    	int flags, Dbt obj, int lock_mode)
    	throws DbException;

# Description

The DbEnv.lock_get method acquires a lock from the lock table, returning information about it in a DbLock object.

The locker argument specified to DbEnv.lock_get is an unsigned 32-bit integer quantity. It represents the entity requesting or releasing the lock.

The flags value must be set to 0 or the following value:

Db.DB_LOCK_NOWAIT
  If a lock cannot be granted because the requested lock conflicts with an existing lock, return immediately instead of waiting for the lock to become available.

The obj argument is an untyped byte string that specifies the object to be locked or released.

The mode argument is an index into the environment's lock conflict array. See DbEnv.set_lk_conflicts and Standard Lock Modes for a description of that array.

The DbEnv.lock_get method may throw an exception encapsulating one of the following values:

Db.DB_LOCK_NOTGRANTED
  A lock was requested that could not be immediately granted and the flags parameter was set to DB_LOCK_NOWAIT.

Otherwise, the DbEnv.lock_get method throws an exception that encapsulates a non-zero error value on failure.

# Errors

If a fatal error occurs in Berkeley DB, the DbEnv.lock_get method will fail and throw a DbRunRecoveryException, at which point all subsequent database calls will fail in the same way.

In addition, if the operation was selected to resolve a deadlock, the DbEnv.lock_get method will fail and throw a DbDeadlockException exception.

In addition, the DbEnv.lock_get method may fail and throw an exception encapsulating a non-zero error for the following conditions:

EINVAL
  An invalid flag value or parameter was specified.

In addition, the DbEnv.lock_get method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods.

### Classes

DbEnv, DbLock

# See Also

DbEnv.set_lk_conflicts, DbEnv.set_lk_detect, DbEnv.set_lk_max, DbEnv.lock_detect, DbEnv.lock_get, DbEnv.lock_id, DbLock.put and DbEnv.lock_stat.`

Copyright Sleepycat Software