jnicli
Interface Database

All Known Implementing Classes:
DatabaseJNI, DatabaseSessionClient

public interface Database

This class is used as interface to local or remote database (through RMI). In case of local connections you should create instance of DatabaseJNI class directly. In case of remote connection, it is necessary to create instance of DatabaseSessionClient class and path reference to the stub object implementing DatabaseSession interface.

Methods of this interface are mostly one-to-one mapped to methods of C++ dbDatabase class. In case of remote application, it should either open or create new database at server using Database.open method, either attach to the existing database using Database.attach method. In case of local application, Database.attach should be used by all application threads except one opened the database.

All database access errors are reported by means of CliException. In case of remote database there are also can be exceptions related with server communication.


Field Summary
static int AUTOCOMMIT
          Select flag AUTOCOMMIT: automatically commit current transaction after completion of selection
static int CLI_DETACH_COMMIT
           
static int CLI_DETACH_DEFAULT
           
static int CLI_DETACH_DESTROY_CONTEXT
           
static int CLI_OPEN_DEFAULT
           
static int CLI_OPEN_NO_BUFFERING
           
static int CLI_OPEN_NO_SYNC
           
static int CLI_OPEN_READONLY
           
static int CLI_OPEN_SEQUENTIAL
           
static int CLI_OPEN_TRUNCATE
           
static int FOR_UPDATE
          Select flag FOR_UPDATE: make it possible to update selected records
 
Method Summary
 void attach()
          Attach thread to the database.
 void close()
          Close database
 void commit()
          Commit current transaction.
 int delete(java.lang.Class table, java.lang.String condition)
          Delete all objects from the table matching specified condition
 void detach(int flags)
          Detach thread to the database.
 long insert(java.lang.Object obj)
          Insert new object in the database.
 void lock()
          Lock database in exclusive mode.
 void open(java.lang.String databasePath, int poolSize, int openAttr, int transactionCommitDelay)
          Open database
 void rollback()
          Commit current transaction Transaction is implicitly started when any database operation is perfromed.
 Cursor select(java.lang.Class table, java.lang.String condition, int flags)
          Select objects from table matching condition
 void update(long oid, java.lang.Object obj)
          Update object with soecified OID
 

Field Detail

CLI_OPEN_DEFAULT

static final int CLI_OPEN_DEFAULT
See Also:
Constant Field Values

CLI_OPEN_READONLY

static final int CLI_OPEN_READONLY
See Also:
Constant Field Values

CLI_OPEN_TRUNCATE

static final int CLI_OPEN_TRUNCATE
See Also:
Constant Field Values

CLI_OPEN_SEQUENTIAL

static final int CLI_OPEN_SEQUENTIAL
See Also:
Constant Field Values

CLI_OPEN_NO_BUFFERING

static final int CLI_OPEN_NO_BUFFERING
See Also:
Constant Field Values

CLI_OPEN_NO_SYNC

static final int CLI_OPEN_NO_SYNC
See Also:
Constant Field Values

FOR_UPDATE

static final int FOR_UPDATE
Select flag FOR_UPDATE: make it possible to update selected records

See Also:
Constant Field Values

AUTOCOMMIT

static final int AUTOCOMMIT
Select flag AUTOCOMMIT: automatically commit current transaction after completion of selection

See Also:
Constant Field Values

CLI_DETACH_COMMIT

static final int CLI_DETACH_COMMIT
See Also:
Constant Field Values

CLI_DETACH_DESTROY_CONTEXT

static final int CLI_DETACH_DESTROY_CONTEXT
See Also:
Constant Field Values

CLI_DETACH_DEFAULT

static final int CLI_DETACH_DEFAULT
See Also:
Constant Field Values
Method Detail

open

void open(java.lang.String databasePath,
          int poolSize,
          int openAttr,
          int transactionCommitDelay)
Open database

Parameters:
databasePath - - path to the database file
poolSize - - size of page pool (in pages), specify 0 to let Gigabase automatically detect pool size
openAttr - - mask of CLI_OPEN_* attributes (0 default value)
transactionCommitDelay - - transaction commit delay (specify 0 to disable)

close

void close()
Close database


select

Cursor select(java.lang.Class table,
              java.lang.String condition,
              int flags)
Select objects from table matching condition

Parameters:
table - class corresponding to the table
condition - SubSQL condition (to select all records pass empty string)
flags - combination of FOR_UPDATE and AUTOCOMMIT flags
Returns:
cursor for selected objects. Cursor can be either incremental, when records are extracted on demand or prefetched. Prefetched cursor is used for remote database and when AUTOCOMMIT flag is set. Prefetched cursor doesn't allow in place updates.

update

void update(long oid,
            java.lang.Object obj)
Update object with soecified OID

Parameters:
oid - OID of updated object
obj - updated object

insert

long insert(java.lang.Object obj)
Insert new object in the database. Object will be inserted in the table with the same name as object class

Parameters:
obj - inserted object
Returns:
OID of inserted object

delete

int delete(java.lang.Class table,
           java.lang.String condition)
Delete all objects from the table matching specified condition

Parameters:
table - class corresponding to the table
condition - SubSQL condition (to delete all records pass empty string)
Returns:
number of deleted objects

commit

void commit()
Commit current transaction. Transaction is implicitly started when any database operation is perfromed.


rollback

void rollback()
Commit current transaction Transaction is implicitly started when any database operation is perfromed.


lock

void lock()
Lock database in exclusive mode. Lock is automatically released when transaction is committed or aborted


attach

void attach()
Attach thread to the database. All threads except the one opened the database should invoke this method before start working with database


detach

void detach(int flags)
Detach thread to the database. All threads except the one opened the database should invoke this method before start working with database.

Parameters:
flags - combination of CLI_DETACH_COMMIT and CLI_DETACH_DESTROY_CONTEXT flags