Java to Lotus Notes connection issue

I am trying to access the data from Lotus Notes database into an external Java program, but no luck.

On my laptop, I have configured IBM Domino 9.0.1 server, where I have created a demo database. My target is, to access the data from this database through external Java code. I have also installed Netbeans and Eclipse on the same laptop where Domino server is configured. Now, I am trying to access the demo lotus notes database in my java program (netbeans/eclipse) using the classes provided in Notes.jar package, but unable to open database.

To accomplish the task, I have followed below steps:

  • Added the path ‘C:\Program Files\IBM\Domino’ to ‘Path’ system variable, and rebooted the laptop.
  • In Netbeans (also tried in Eclipse), created Java class (console application), added Notes.jar file (IBM/Domino/JVM/lib/ext/Notes.jar) in the classpath (in netbeans, added Notes.jar in Resources section. In Eclipse, copied Notes.jar in lib folder).

Added the following code in the class: (assume lotus.domino.* is already imported in the code)

public static void main(String args) { try{ NotesThread.sInitThread(); //Case1 Session session = NotesFactory.createSession()//Connect the server with server ID. Throws error ‘Database has not been opened yet’; //Also tried following options. Note that I have assigned full access/manager rights to anonymous user on the demo database //Case2 //Session session = NotesFactory.createSession((String)null);//Same result as first one [NotesFactory.createSession()] //Case3 //Session session = NotesFactory.createSession((String)null,“Romil Handoo/dev”,“My_Domino_Internet_Password”);//Connect the server as Romil Handoo/dev login. Throws error- Invalid User Id/Password. I am giving correct ID/password //Case4 //Session session = NotesFactory.createSession((String)null,“”,“”);//Access with anonymous user. Throws error ‘Database has not been opened yet’** Database dbDemo = session.getDatabase(session.getServer(), “demo/DemoDB.nsf”); //session.getServer() is returning my server name, which is Development/home. //Also tried these, but same result each time: //session.getDatabase(“localhost:9595”,“demo/DemoDB.nsf”) //session.getDatabase(“localhost”,“demo/DemoDB.nsf”) //session.getDatabase(“127.0.0.1:9595”,“demo/DemoDB.nsf”) //session.getDatabase(“127.0.0.1”,“demo/DemoDB.nsf”) //session.getDatabase(“”,“demo/DemoDB.nsf”) //session.getDatabase((String)null,“demo/DemoDB.nsf”) //Following line throws exception ‘Database has not been opened yet’ View vwDemo = dbDemo.getView(“vwDemo”); } catch(Exception ex) { System.out.println(ex.toString()); //For case 1, case 2, and case 4, error message is ‘Database has not been opened yet’ //For case 3, error message is ‘Invalid login id/password’ } finally { NotesThread.stermThread(); } }

Please someone guide me how I may connect to domino database through external java code? For all these steps, I have referred the page IBM Documentation https://www.ibm.com/support/knowledgecenter/en/SSVRGU_9.0.1/basic/H_NOTESDATABASE_CLASS_JAVA.html

Many thanks

Subject: Perhaps it is the database ACL?

I am no Java developer, but perhaps you need to check the database ACL?

As a test, attribute ‘Manager’ access to ‘Anonymous’ and ‘Default’ users and see if you are able to access the database thereafter.

If so, it’s a simple security issue.