Skip to Content

Connecting MDM

Getting the Connection:

A connection is a MDM Network connection on top of TCP/IP which builds a layer that can be used by multiple sessions. I will explain everything about sessions in the next section (Getting the Session). The connection is made on the standard port (20005) unless specified different (See code sample).Any operation on MDM requires getting a connection to the MDM server.
There are two different ways to connect to MDM server. You can use the SimpleConnectionFactory or the ConnectionPoolFactory.
Both of the factory classes give you a connection (ConnectionAccessor) to the MDM.
For detailed Information see:

Link to MDM Java API – ConnectionAccessor

Link to MDM Java API – Connection SimpleConnectionFactory

Link to MDM Java API – ConnectionPoolFactory

The SimpleConnectionFactory will give you a new connection instance every time it’s called.

But first some sample Code to get a simple connection:

// Init the SimpleConnection variable
private SimpleConnection connection;

 * The method will return a ConnectionAccessor which is needed every time
 * you want to execute a Command like searching or as on any other Command
 * there is.
 * @return SimpleConnection to MDM Server

public ConnectionAccessor getConnection() {

  String sHostName = MyServerName;

  // We need a try / catch statement or a throws for the method

  try {
   /* retrieve connection from Factory
     * The hostname can be the name of the server if it is listening on the standard port 20005
     * or a combination of Servername:Portnumber eg. MDMSERVER:40000
   connection = SimpleConnectionFactory.getInstance(sHostName);
  } catch (ConnectionException e){
    // Do some exception handling
  // return the connection or if an exception occured a NULL value
  return connection;


 * Method that will terminate the connection to MDM Server.
 * Connections should to be terminated if not used anymore.
 * If not terminated the connection will be kept open on the server
 * until the MDM server process is restarted. You can check the open connections
 * in the MDM console in the Admin section of the repository
public void closeConnection(SimpleConnection scConnection) {
       // Close the connection to the server


Using the SimpleConnectionFactory.getInstance() Method will return a ConnectionAccessor. This connection accessor is needed to execute any kind of command. The normal start of a command for example is:

/** Build the search on table Products */

Search seMDMType= new Search(REPSCHEMA.PRODUCTS.TBL);

/** Build the command to get all records */
rlrcGetTypes = new RetrieveLimitedRecordsCommand(mySimpleConnection);

/** Set parameters for the command */
// Set the Session
// Set the Search
// Set the mResultDefinition
/** Try to execute the command */
try {
} catch (CommandException e) {
       // TODO Auto-generated catch block

The code should be an example and will not be explained yet. But the most important line of code I wanted to point out is:

(new RetrieveLimitedRecordsCommand(mySimpleConnection);)

As you can see there is a ConnectionAccessor (mySimpleConnection) in this constructor call. A good practice would be to retrieve a connection once and keep it stored for further operations on MDM.

In my projects I have build an MDMConnection Object that will store the needed Information on connection, session, and user credentials used to authenticate the session. I will explain all the elements in detail a little bit later.

Getting the Session:

As I just mentioned there is also a Session that we need to open to the repository. The session uses the connection already made.

In general there are three different kinds of connections and depending on the thing you want to do, you will need a different kind. But let me point out the three different kinds available:

  1. Server session:
    A server session is used for management operations of a running MDM Server. This could be mounting- or unarchive a repository. You could even stop the server with this kind of session if needed. In fact u could say that the operations done with MDM Console partly need a server session.
    The associated command would be: CreateServerSessionCommand

  2. Repository Session:
    A repository session is bound to a specific repository and is used for management operations. Operations could be CRUD (Create, Read, Update, Delete) on Repository elements (user roles, model data such as fields, tables…) not the data in the repository itself. Same as with the server session we could say that a repository session is partly needed by the MDM Console.
    The associated command would be: CreateRepositorySessionCommand

  3. User session
    A user session is used for any operation that might be performed by the MDM Datamanager. Basically any kind of data manipulation is done using a user session (CRUD of Data). So having this session we will be able to perform searches, creating, updating and deleting data records.
    The associated command would be: CreateUserSessionCommand

As an example I want to post the code to create a user session to an MDM Repository and authentication of it:

 * Create and authenticate a new user session to an MDM repository.
 * @throws ConnectionException
 *   is propagated from the API
 * @throws CommandException
 *  is propagated from the API

public String getAuthenticatedUserSession(ConnectionAccessor mySimpleConnection) throws ConnectionException, CommandException{
   * We need a RepositoryIdentifier to connect to the desired repository
   * parameters for the constructor are:
   * Repository name as string as read in the MDM Console in the "Name" field
   * DB Server name as string as used while creating a repository
   * DBMS Type as string - Valid types are: MSQL, ORCL, IDB2, IZOS, IIOS, MXDB
   RepositoryIdentifier repId = new RepositoryIdentifier(RepositoryNameAsString, DBServerNameAsString, DBMSTypeAsString);

   // Create the command to get the Session
   CreateUserSessionCommand createUserSessionCommand = new CreateUserSessionCommand(connection);

   // Set theidentifier

   // Set the region to use for Session - (Language)

  // Execute the command

  // Get the session identifier
   String session = createUserSessionCommand.getUserSession();

   // Authenticate the user session
   AuthenticateUserSessionCommand authenticateUserSessionCommand = new AuthenticateUserSessionCommand(mySimpleConnection);
   // Set the created session to use with command
   // Set the username to be used for authentication
   // Set the password to be used for authentication
   // Execute the command

   // For further information see:
   // Create the normalization command
   SetUnicodeNormalizationCommand setUnicodeNormalizationCommand = new SetUnicodeNormalizationCommand(mySimpleConnection);
   // Set the session to be used
   // Set the normalization type
   // Execute the command
   // Return the session identifier as string value
   return session;

In general you have to keep in mind that getting the connection and authenticating it is a pretty time consuming operation. In most cases this operation will take up to two seconds or more. This might not sound like a very great amount of time, but if you are creating a Web application it will be. So try to connect to the repository a less as possible. Reusing the connection and session will help save expensive time.

In my next Blog I will show you a way to authenticate user sessions without a password (Trusted Connection). This could be helpful in a SSO ( Single Sign On) Scenario, where the user has already authenticated against a portal or any other authentication mechanism.

Then I would like to show you how to work with commands and point out a way to save some time in accessing the Fields of a repository. At first I will show how to perform searches and then I will dive into data manipulation (CRUD).

Hope this Blog helped a little to dive into the MDM Java API 2.


Best regards,


Any comments are very welcome!

First Post:

MDM Java API 2 an introductive series part I

Beginning to program MDM Java API 2 causes the need to a quick introduction into the theory of MDM and the Java API 2. This Blog is the first of a series to introduce beginners into the topic. A lot of Code examples will illustrate the theory explained. This is the first part. 

MDM Java API 2 an introductive series part III

This is the third part of my introductive series on MDM Java API 2 telling you about getting an authenticated user session on a trusted connection.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

  1. Shruti Shah
    Its really nice blog.
    te blog explains the Simpleconnection. closing of simple connection,
    Can you also provide the code for connectionpool Factory? specially how to close that connection?

Leave a Reply