Reputation: 33
I'm trying to get the current database from a servlet that uses a Java Class but I'm not able to do it without extending AgentBase in that Class. I mean, I want to know the current database of a Java Class, is that possible?
I'm using the servlet for authentication, and then I want to save some login information into a document, but for that I need the current database. I read this question before but I'm not 100% sure wether this is possible or not.
Thanks in advance!
Upvotes: 0
Views: 249
Reputation: 124
There are several ways to invoke the Domino classes. Outside AgentBase, getting the current session involves the instantiation of a NotesFactory.
Check the examples at https://www.ibm.com/support/knowledgecenter/en/SSVRGU_9.0.1/basic/H_EXAMPLES_COMPILING_AND_RUNNING_JAVA.html ; one of those ways of invocation should be appropiate for your use case.
Upvotes: 0
Reputation: 1068
Hi Maybe this link helps https://flylib.com/books/en/1.480.1/writing_java_servlets.html or http://hasselba.ch/blog/?p=2307
Or have look a the Notes Designer Help: NotesThread.sinitThread()
Upvotes: 0
Reputation: 18408
It seems you've got things upside down and backwards. From the java language perspective, there is never any such thing as a "current database" tightly associated with (i.e. as a property of) a given java class.
Java classes are just software, just software is intended to be just deployed to some runtime environment, where "which database to connect to" is part of the [information contained/configured in that] runtime environment. That's intentional and by design, because otherwise it would even be impossible to first test anything in a test environment before deploying it as tested to a production environment.
So by definition, "the current database" (whatever that means) can only be obtained from looking at the runtime configuration (whatever that looks like and wherever that's to be found).
Upvotes: 3
Reputation: 11
AgentBase has a getSession() method and Session has a getCurrentDatabase() method.
Upvotes: 0
Reputation: 1641
The Session class has an AgentContext property which contains a getCurrentDatabase(). https://www.ibm.com/support/knowledgecenter/en/SSVRGU_9.0.1/basic/H_CURRENTDATABASE_PROPERTY_JAVA.html
Upvotes: 0