cancel
Showing results for 
Search instead for 
Did you mean: 

Access Repository via external call (Java API)

Solved
New Contributor

Access Repository via external call (Java API)

I need some help.

 

I try to connect my MEGA Database via a program in Java (Eclipse), but i don't know how to do this. I want to access at my object and to do some operations like for example getCollection of my objects etc...

 

In VB we must do this:

 

Dim oMegaCurrentEnvironment As New MegaCurrentEnv // Connect to the Current environment
Dim oMegaRoot As MegaRoot // My root ObjectSet 
oMegaRoot = oMegaCurrentEnvironment.GetRoot // Get the root object of my MEGA DB

 

But how to achieve this via JAVA API ?

 

For the moment i got this :

 

public class Main {

    public static void main(String[] args)
    {    
        MegaCurrentSession session = new MegaCurrentSession();
        boolean ouvert;
        ouvert = session.isSessionOpen();
        if (ouvert)
        {
            System.out.println("Session is openned ! How do I take my objects now?");
        }
        
        MegaCurrentEnvironment ouverture;
        MegaRoot mgRoot;
        mgRoot = ouverture.getRoot(null);
     }

}

 

But my variable 'ouverture' need to be initialise, i don't know how to initialise it.

 

 

 

I hope to be clear.

 

Sincerely yours,

 

Benjamin Rassat, B&T Associés
Tags (2)
3 Replies
Contributor

Re: Access Repository via external call (Java API)

The java API has a function with the same name:

MegaRoot root = session.getRoot(null);

New Contributor

Re: Access Repository via external call (Java API)

Thanks Alros. That is working now.

But what the difference between MegaCurrentEnvironment and MegaCurrentSession ?

Benjamin Rassat, B&T Associés
Highlighted
Contributor

Re: Access Repository via external call (Java API)

To our understanding, a Session represents a Transaction and an Environment is about the Database, Metadata etc. The MegaCurrentEnvironment and MegaCurrentSession are just bad names for an opened Session / Environment. For lack of better documentation, this may or may not be true though.

 

In our plugins we only use the MegaRoot object otained from a Session.