0
votes

So I need to get some information from lotus domino database with java.

At first I need to create a session:

Session session = NotesFactory.createSession(host, user, password);

Then I need to get database:

Database db = session.getDatabase(serverName, dbName);

At the next step i need to get information. How this db looks comparable to simple relation db? I mean that in relation db I can make SQL query like "SELECT table FROM room WHERE table.hieght < 10" and for example how that query will look to get the same inforamtion from Lotus Domino DB?

1
Notes Databases are not relational.Simon O'Doherty
I know. But the question is how inforamtion looks comaparable to relation DB and how to get this information?Kirill Bazarov

1 Answers

4
votes

Notes uses a document-oriented database called NSF (Notes Storage Facility) to manage semi-structured data like rich text and files. The data is stored as documents and views unlike relational databases.

To query NSFs you can use the Java API but they are hard to use especially if you are used to relational databases and standart Java collections. (i.e. most of the collection return types are not iterable so you have to use while to iterate through them :S, also expect a lot of weird exceptions). Here is an example:

Session session = NotesFactory.createSession(host, user, password);
View view = session.getDatabase(DATABASE).getView(VIEW);
ViewEntryCollection allEntries = view.getAllEntries();
ViewEntry entry = allEntries.getFirstEntry();
while (entry != null) {
    if (entry.isDocument()) {
        Document doc = entry.getDocument();
        String no = doc.getItemValueString("No");
    }
    entry = allEntries.getNextEntry();
}

Using the above code I retrieved a field labeled as "No" on a notes document which I got from a collection of entries which ultimately form a view named VIEW, and that view is under the database DATABASE.

There is also a scripting language called Lotus Domino Formula Language which is also used to query NSFs, you can learn about that here: Lotus Programming Guide and Formula Language.