‎23-04-2015 10:51 AM - edited ‎23-04-2015 11:45 AM
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,
Solved! Go to Solution.
‎28-04-2015 09:22 AM
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.
‎23-04-2015 04:43 PM
Thanks Alros. That is working now.
But what the difference between MegaCurrentEnvironment and MegaCurrentSession ?
‎23-04-2015 04:27 PM
The java API has a function with the same name:
MegaRoot root = session.getRoot(null);