Connect to Notes DB using JAVA

Is there a way a J2EE/JAVA Application can talk to a notes server
to import the company's addressbook (via JDBC or maybe an API.
I'm using JBOSS as an app server on a unix machine. Points
will be increased for really helpful answer.
LVL 5
apparitionAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

qwaleteeCommented:
Yes.  There is a JDBC driver for NOtes.  I am not certain, but I believe it requires that Notes client or DOmino server is installed on teh machine where the driver is used.  You would select from the "table" named Person in the database names.nsf. (Names.nsf is teh DOmino directory.  Some companies use a separate database for the company directory, instead ofthe Domino built-in directory, which is similar to, and compatible with, LDAP directories).

f you are using names.nsf, tell me which fields you need to pull, and I will tell you which columns match. If you are using something besides names.nsf, I would have to know the structure.

You can also access the data via the DOmino object model, which is exposed to Java.  You would use Session.getDatabase (the core object) to return a Database, Database.getView to retrun a view (index) of all data you need, and, if you want to keep teh code siple, use View.getFirstDOcument / View.getNextDocument to return individual records.  Within the record, there are many methods to retrieve fields as vectors of (usually string) values, or to return teh fields themselves as Item objects.
apparitionAuthor Commented:
JDBC will only work on a windows machine. I think the Java Toolkit available on the notes website should be used for
what I want to do. Has anyone used the java toolkit?
heres the link

http://www-10.lotus.com/ldd/notesua.nsf/a08df36b2299a8bc8525665d006dce40/c3bf8b8e9920c7d4852569810055a661?OpenDocument 
qwaleteeCommented:
The toolkit is the same as the Domino Object Model.

The object odel is almost the same across multiple acces points... internal LotusScript, internal Java, OLE automaion, external Java code running on a Domino/Notes box, external Java code running over CORBA.

I've done a few systems using the CORBA bridge.  Mostly, though,  use local installs, and Java access is a niche in the first place.

Let me know if you have any specific questions, and I'll try to answer them.  I really can't give you a broad overview, it would not make sense in this forum.  What data do you specifically expect to read from/write to in Domino?
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

apparitionAuthor Commented:
This is what I need to do exactly,

I have a JSP/JAVA web application sitting on a unix box as I mentioned before I need to create a page in the
application that will display my company's adress book from a notes DB(names.nsf) sitting on a different server.
apparitionAuthor Commented:
I have downloaded the toolkit and trying to get it work on my local machine that has designor installed.
qwaleteeCommented:
You might want to use LDAP instead, as you can use some run of the mill classlibs to access the Domino directory data that way.

Which particular page of the directory are you trying to display?  I can proably give you some sample code.
apparitionAuthor Commented:
all I need to do is display a list of all the names
qwaleteeCommented:
Then LDAP will do quite nicely.

However, if you insist...

            try {
                  Session session = getSession();
                  AgentContext agentContext = session.getAgentContext();
                  
                  Database nab = session.getDatabase( "" , "names.nsf" );
                  View peopleView = nab.getView("People");
                  ViewNavigator peopleNav = peopleView.createViewNav();
                  ViewEntry row = peopleNav.getFirst();
                  while(row!=null) {
                        Vector v = row.getColumnValues();
                        for (int i=0; i<v.size(); i++) {
                              if (v.elementAt(i) != null) {
                                    System.out.println("Column " + (i+1) + ":\t" + v.elementAt(i));
                              }
                        }
                        System.out.println();
                        row = peopleNav.getNext(row);
                  }



            } catch(Exception e) {
                  e.printStackTrace();
            }
apparitionAuthor Commented:
This is not the part of the code I am having a problem with I dont know how to connect
to my notes server since its on a different box from where my web application is
qwaleteeCommented:
OK.  There are two ways to run Java against Notes.  You either have Notes or DOmno installed locally, or you use CORBA/IIOP.  Since you are runing on Unix, and the Notes client is not available on Unix, then a local run would require a locally installed Domino server.  I assume that's unlikely, so we'll focus on CORBA/IIOP.

The srever has to run the IIOP task (actually called DIIOP), as well as the HTTP task.  You may need to modify some of the security settings for the server., and possibly network settings that Domino uses -- but you probably will not have to.

On the "client" (JBoss):

You will need to obtain NCSO.jar, which you can get from the Domino server install.  Put it in the CLASSPATH.  Import lotus.domino.* -- if your coding conventons preclude you from using wildcard, let me know, and we can discuss what you need to import; yuo can probably figure that out yourself, though.

Session is instantiated as follows:
Session session = NotesFactory.createSession(Domino_host, userName, password);

All three parameters are strings.
Domino_host is the Domino network address, whether hostname or IP.
UserName is a canonical name listed in the Domino directory, e.g., Apparition/Systems/IT/AcmeCorp
Password is the HTTP password asigned to UserName.  If you have any questions about this, you need to talk to the Domino administrator, because sometimes companies protect access to password setup, or require you to go through a custom process.  Normally, Domino allows you to edit the Internet Password field on your directory Person document.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
apparitionAuthor Commented:
Perfect this answers my question. I downloaded the NCSO.jar but wasn't sure if I could connect remotely to notes remotely. I have already talked to my notes admin and he's setting up the notes server settings. Thankyou but I only have 45 points right now I will give you more points when I get them
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.