getDatabase (Session - Java)

Creates a Database object that represents the database located at the server and file name you specify, and opens the database, if possible.

Defined in

Session

Syntax

public Database getDatabase(String server, String db)
    throws NotesException
public Database getDatabase(String server, String db, boolean createonfail)
    throws NotesException

Parameters

String server

The name of the server on which the database resides. Use null to indicate the session's environment, for example, the current computer. Must be null for remote (IIOP) operations.

String db

The file name and location of the database within the Domino® data directory. Use a full path name if the database is not within the Domino® data directory.

boolean createonfail

If true or omitted, creates a Database object even if the specified database cannot be opened. If false, returns null if the database cannot be opened.

Note: Setting this to true will not create the database on disk. It will create the in-memory object that refers to the non-existent database. isOpen will return false. No method currently exists to create a blank database using the Java API. You must use a template.

Return value


Database

A Database object that can be used to access the database you have specified, or null if the database cannot be opened and createonfail is false. If the database cannot be opened and createonfail is true or omitted, isOpen is false for the Database object.

Usage

An error is returned if the user does not have access rights to the database or server.

A Java application running on the same machine as a Domino® server cannot open a local database from a local session. Use a remote (IIOP) session to access the database.

See the Database class for additional descriptions and examples.

Example