Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to write a program that would dump a whole lotus notes database to a file via NotesSQL driver. I'm connecting via jdbc:odbc and have

I can execute selects and get data from Lotus notes database

here is the code

try {
    System.out.print("Connecting... ");
    Connection con = DriverManager.getConnection("jdbc:odbc:NRC", "UserName", "Passw0rd1337");
    System.out.println("OK");
    DatabaseMetaData dmd = con.getMetaData();
    String[] tableTypes = new String[] {"TABLE", "VIEW"};
    ResultSet rs = dmd.getTables(null, null, "%", tableTypes);
    ResultSetMetaData rsd = rs.getMetaData();
    while (rs.next()) {
        for (int i=1; i<=rsd.getColumnCount();i++)
            System.out.println(i+" - "+rsd.getColumnName(i) + " - " + rs.getString(1));
    }
    con.close();
    System.out.println("Connection closed");
} catch (Exception e) {
    System.out.println(e);
}

And is there a better way to connect to Lotus notes databases via NotesSQL? Because with my code i get only null values for the names...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
350 views
Welcome To Ask or Share your Answers For Others

1 Answer

I know you are trying to use JDBC and NotesSQL. But, depending on your needs, and using Eclipse, you can access Notes databases natively via Java, which frankly is alot easier than trying to use JDBC, bit of a square peg in a round hole when you're using JDBC with Domino. Even if you don't have Lotus Notes installed on the host machine you can still write and deploy java applets and servlets to get into the data.

You will need to get the relevant Lotus Domino jar's though. So, my recommendation is an alternative approach to JDBC.

So, providing you have the Lotus Domino jar files in your Eclipse project you should be able to code any kind of extract from a view or even run adhoc searches on a database.

Setup

If this sounds like the direction you need to go, then firstly, have a look at setting up Eclipse with relevant Notes jar's here. There are only a few. (Sometimes you'll read about using CORBA and/or IIOP. Try avoid that, it's just a world of hurt).

Samples and snippets

This developer works article (although 6 years old) still works for Domino and is a sound foundation for the approach I am advocating. That article starts to address the initialization of the NotesFactory and Session classes to get you into the Notes API. More online help here for the NotesFactory class.

If you have a Lotus Notes client available you can have a look through code snippets here. A classic example for accessing documents via Views in Java can be found here.

After that you can easily access Views and documents with examples from here, and learn from the guru, (Bob Balaban), about memory management here.

If you're processing high volumes or running servlets, then memory management is important, otherwise don't stress about it too much. You can execute Native searches on a Notes database by writing it in formula, and then using the "search" methods to execute the query natively.

Iterating through documents or views ?

The easiest approach is to traverse documents via views and/or use "getdocumentByKey" methods to get a collection and work on that. In Domino "Views" are the equivalent of Tables. You can also get a list of Views via the Database.Views property

Native Queries

It's difficult to find definitive instructions on native queries for Notes, but I have managed to find it online here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...