*I"Berkeley DB: Db.put[P

Db.put





import com.sleepycat.db.*;

:public void put(DbTxn txnid, Dbt key, Dbt data, int flags) throws DbException;





Description



8The Db.put method stores key/data pairs in the database.

HIf the database supports duplicates, the Db.put method adds the new dataGvalue at the end of the duplicate set. If the database supports sortedJduplicates, the new data value is inserted at the correct sorted location.

;If the file is being accessed under transaction protection,<the txnid parameter is a transaction ID returned fromQDbTxnMgr.begin, otherwise, NULL.

CThe flags parameter must be set to 0 or one of the followingvalues:

K

Db.DB_APPEND
Append the key/data pair to the end of the database.AFor Db.DB_APPEND to be specified, the underlying database must beof type Db.DB_RECNO.FThe record number allocated to the record is returned in the specified key._

Db.DB_NOOVERWRITE
Enter the new key/data pair only if the key does not already appearin the database.


;The default behavior of the Db.put function is to enter theFnew key/data pair, replacing any previously existing key if duplicatesFare disallowed, or to add a duplicate entry if duplicates are allowed.<Even if the designated database allows duplicates, a call to<Db.put with the DB_NOOVERWRITE flag set will fail if the keyalready exists in the database.

The Db.putHmethod throws an exception that encapsulates an errno on failure,Eand DB_KEYEXIST if the DB_NOOVERWRITE flag was set and the keyalready exists in the file.



Errors

NIf a fatal error occurs in Berkeley DB, the Db.put method may fail and throw a}
DbRunRecoveryException, at which point all subsequent database%calls will also fail in the same way.

The Db.put&method may fail and throw an exceptionKfor any of the errors specified for the following Berkeley DB and C library functions:6Db.cursor,DBcursor->c_close(3),2Dbc.get,DBcursor->c_put(3),__account_page(3),dbenv->db_paniccall(3), fflush(3), fprintf(3),free(3),func(3),>DbLockTab.get,8DbLock.put,>DbLockTab.vec,6DbLog.put, malloc(3), memcpy(3), memmove(3),BDbMpoolFile.get,BDbMpoolFile.put,BDbMpoolFile.set, memset(3), realloc(3), strerror(3), vfprintf(3),and vsnprintf(3).

In addition, the Db.put&method may fail and throw an exceptionencapsulating errnofor the following conditions:

D

EACCES
An attempt was made to modify a read-only database.


(

EAGAIN
A lock was unavailable.


B

EINVAL
An invalid flag value or parameter was specified.

#A record number of 0 was specified.

CAn attempt was made to add a record to a fixed-length database thatwas too large to fit.

(An attempt was made to do a partial put.



@

ENOSPC
A btree exceeded the maximum btree depth (255).




Class

-Db



See Also

4Db.close,6Db.cursor,0Db.del,.Db.fd,0Db.get,HDb.get_byteswapped,:Db.get_type,2Db.join,2Db.open,Db.put,1Db.statand2Db.sync.
ÿÿ