import com.sleepycat.db.*;public void put(Dbt key, Dbt data, int flags) throws DbException;
The Dbc.put method stores key/data pairs into the database.
The flags parameter must be set to one of the following values:
In the case of the recno access method, it is an error to specify DB_AFTER if the underlying recno database was not created with the DB_RENUMBER flag. If the DB_RENUMBER flag was specified, a new key is created, all records after the inserted item are automatically renumbered, and the key of the new record is returned in the structure referenced by the parameter key. The initial value of the key parameter is ignored. See Db.open for more information.
If the cursor is not yet initialized or a duplicate sort function has been
specified, the Dbc.put function will return EINVAL.
In the case of the recno access method, it is an error to specify DB_BEFORE
if the underlying recno database was not created with the DB_RENUMBER flag.
If the DB_RENUMBER flag was specified, a new key is created,
the current record and all records after it are automatically renumbered,
and the key of the new record is returned in the structure referenced by
the parameter key.
The initial value of the key parameter is ignored.
See Db.open for more information.
If the cursor is not yet initialized or a duplicate sort function has been
specified, Dbc.put will return EINVAL.
The key parameter is ignored.
If a duplicate sort function has been specified and the data item of the
current referenced key/data pair does not compare equally to the data
parameter, Dbc.put will return EINVAL.
If the cursor is not yet initialized,
Dbc.put will return EINVAL.
If the key already exists in the database,
and a duplicate sort function has been specified, the inserted data item
is added in its sorted location.
If the key already exists in the database,
and no duplicate sort function has been specified, the inserted data item
is added as the first of the data items for that key.
The DB_KEYFIRST flag may not be specified to the recno access method.
If the key already exists in the database,
and a duplicate sort function has been specified, the inserted data item
is added in its sorted location.
If the key already exists in the database,
and no duplicate sort function has been specified, the inserted data item
is added as the last of the data items for that key.
The DB_KEYLAST flag may not be specified to the recno access method.
If the cursor record has been deleted, Dbc.put will return DB_KEYEMPTY.
Otherwise, the Dbc.put method throws an exception that encapsulates an errno on failure.
If Dbc.put fails for any reason, the state of the cursor will be unchanged. If Dbc.put succeeds and an item is inserted into the database, the cursor is always positioned to reference the newly inserted item.
The Dbc.put method may fail and throw an exception for any of the errors specified for the following Berkeley DB and C library functions: __account_page(3), abort(3), dbenv->db_paniccall(3), dbp->dup_compare(3), fflush(3), fprintf(3), free(3), func(3), hcp->dbc->dbp->h_hash(3), DbLockTab.get, DbLock.put, DbLockTab.vec, DbLog.put, malloc(3), memcmp(3), memcpy(3), memmove(3), DbMpoolFile.get, DbMpoolFile.put, DbMpoolFile.set, memset(3), realloc(3), strerror(3), vfprintf(3), and vsnprintf(3).
In addition, the Dbc.put method may fail and throw an exception encapsulating errno for the following conditions: