Database Reference
In-Depth Information
instance returned by the getApplication method contains a collection of databases. The
IEssOlapApplication.getCube method returns a specific IEssCube object by name.
// set the cube active
cube.setActive();
many operations in Essbase require that a database be set active. In fact, you may
have noticed numerous messages in your Essbase.log file similar to this log entry.
[Sun Dec 11 21:59:54 2011]Local/ESSBASE0///4728/Info(1051009)
Setting application Sample active for user [timt]
The Classic Add-in, Smart view, and your custom Java API code will add similar
messages to the log when you set the cube active.
There are a couple of other considerations you need to make when you write Java API
code against Essbase. First, you must either explicitly handle any exceptions that may
occur in the code or you must explicitly flag your code such that any procedure that calls
your code is forced to handle the exception. In the Java API, any Essbase exception is
raised within an EssException object instance. to handle the EssException in your code,
use a normal Java try/catch block.
The other thing you must consider is cleaning up connections that you make to
Essbase. In other words, if you connect to an Essbase database, you must disconnect
when you are done so that your application does not leave hanging connections. The
most obvious thing to do is to simply disconnect your Essbase connection as the last line
in your application. That strategy is fine as long as you code executes normally, but what
happens if there is an exception? If you simply have the code to disconnect from Essbase
as the last line in your program, there is no guarantee that that line will execute. In fact,
if an exception occurs, then it is unlikely that the last line of your program will execute.
how do you guarantee the disconnect code executes? Simple. The try/catch/finally block
can provide this functionality for you. The try/catch/finally block is used to execute code
and catch specified exceptions. regardless of the code path taken, be it normal comple-
tion or an exception, the finally block executes, so it is a great place to put your cleanup
code. Do not forget, however, to protect your disconnection code from exceptions. here
is a general pattern you can use with Essbase:
IEssbase essbase = null;
IEssOlapServer server = null;
try {
// initialize the JAPI
essbase = IEssbase.Home.create(IEssbase.JAPI_VERSION);
// connect to the server
server = essbase.signOn("timt", "essbase", false, null,
"embedded", "mustang");
} catch (EssException e) {
// very simplistic exception handling
e.printStackTrace(System.out);
} finally {
// cleanup here
try {
if (server != null && server.isConnected())
Search WWH ::




Custom Search