Failed to create a local session by using Domino JAVA API, ERROR: Database has not been opened yet

On notes side, I created a local nsf called localNSF.nsf. Then I wrote code try to access this nsf. I do not have Domino started, and nsf is only in the …/Lotus/Notes/data folder. The code are as follow:

[code]-------------------------------------------------------

lotus.notes.NotesThread.sinitThread();

lotus.domino.Session localSession = null;

try {// ------------- try to get a local session

        localSession = NotesFactory.createSession();

    } catch (NotesException e) {

        e.printStackTrace();

    }

if(localSession == null){

        System.out.println("failed to get local session.");

    }else{

        System.out.println("got local session.");

    }

//----------- register the id file

    String idfile = "D:\\Program Files\\Lotus\\Notes\\data\\user.id";

    Registration r;

    try {

        r = localSession.createRegistration();

        r.switchToID(idfile, password);

    } catch (NotesException e1) {

        // TODO Auto-generated catch block

        e1.printStackTrace();

    }

//------------- try to get database

    lotus.domino.Database db = null;

    try {

        db = localSession.getDatabase("","localNSF");

    } catch (NotesException e) {

        e.printStackTrace();

    }

    

    if(db == null){

        System.out.println("failed to get local db.");

    }else{

        System.out.println("got local db.");

    }

    

    try {

        System.out.println("db title = " + db.getLastModified());

    } catch (NotesException e) {

        e.printStackTrace();

    }



    lotus.notes.NotesThread.stermThread();

[/code]-------------------------------------------------

before execute the code above, I include the location of notes.jar, ncso.jar and nlsxbe.dll in the PATH.

then when executing the code, I could getSession() ‘successfully’, I mean the ‘localSession’ is not null; then I could get database, it mean ‘db’ is not null; but when doing ‘db.getLastModified()’ call, I caught the following error:

[error] -----------------------------------------------

NotesException: Database localNSF.nsf has not been opened yet

at lotus.domino.local.NotesBase.PropGetDate(Native Method)

at lotus.domino.local.Database.getLastModified(Unknown Source)

at LocalSessionTry.main(LocalSessionTry.java:62)

[/error] -----------------------------------------------

Could anybody shed light on this?

Subject: failed to create a local session by using Domino JAVA API, ERROR: Database has not been opened yet

You’ve only got a handle to the database, but you havent opened it.

You need a db.Open() before trying to access the database properties.

Subject: RE: failed to create a local session by using Domino JAVA API, ERROR: Database has not been opened yet

yes, it seems to be the location of the database.

I thought if I create a local session, it is a session to a particular notes client(not domino), so if I call getDatabase() of the session, it see …/Notes/data as the default folder to get database.

But after some test, I found it sees …/Domino/data as the default folder. So when executing my previous code, there is no database ‘localNSF’ there under …/Domino/data, and the database was not gained indeed.

For now, to access a database locates at some places other then the default one, I should give the full path of the database.