The IBM ODM Decision Center and the Rule Execution Server values are stored, by default, in a Derby database that comes with the IBM ODM suite installation. During a rules development project we sometimes need to access these values and insert them on an external database or update this external database accordingly. In this post I will show you how to connect to an external Datase with the ODM API in java and execute a simple query after collecting Decision Center values. You can use this method in your project with any values you need from the Decision Center.
To understand the basics of the ODM API, please refer to my previous post about the IBM ODM API here.
- Preparing Decision Center Values
- Connecting to an External DB
- Let’s create a new Java class with the Connection details.
- It is a good practice to have the value of the connection datasource in a properties file.
- Create a getConnection() method in the DBConnection class and add the following structure:
- Return the con variable and call this method from the main ODM API java class:
Now you are ready to execute any statement in the external DB using the Decision Center variables. Query statement sample: ps = con.prepareStatement(“INSERT INTO db.dt VALUES (‘”+ruleProject.getName())
I hope you enjoy this tutorial and please feel free to contact me with any query or feedback, thank you!
In many IBM ODM rules implementation projects we are going to have requirements that involve working with the IBM ODM API. Even though the Decision Center has a lot of powerful features to customize our rules, there are some things that can only be achieve by working with the API, this means we will have to work with java code and be familiar with the ODM API classes to accomplish our goals. In this tutorial I will show you the basics of how to establish a connection with the Decision Center from the Rule Designer and retrieve valuable project information. You can apply this for your particular requirement.
- Getting familiar with ODM API
- We first need to take a moment and review some of the most important classes in the IBM ODM API documentation (IlrSession) , it’s ok if you don’t fully understand how they work at first. It is all about practice.
- Enter here to access the documentation.
- Creating a Java project
- Establishing the decision center connection
- Create a new main class to test our remote ODM API decision center connection
- Our java class needs to implement the IlrSession class:
- Create your connection parameters, in my case:
- Now in our main class we need to create an object of the IlrSessionFactory class that implements IlrRemoteSessionFactory
- Lets call the connect method:
- Tip: be sure to work in a try/catch block to manage any connection exceptions
- Obtaining Decision Center data
We can work and obtain pretty much any data, object or method that is inside the Decision Center repository. We can also create our custom jar classes and repackage the teamserver.ear with it.
I hope you enjoy this tutorial and please let me now if you need help working with the ODM API and what do you want to see next. Thank you!