Create ODI repository using SDK

Create ODI repository using SDK:

I got excited after looking the GUI program using swing builder by David. Refer this. This is really interesting for me.I will try to inherit these things to customize my requirements.

So for groovy you can follow the above link and for SDK you can use below codes. It covers creating both master repository and work repository. I know 0.1 percent people would like to upgrade using SDK. LOL 😀 . But i will definitely write on this in my next post.

import oracle.odi.core.OdiInstance;
import oracle.odi.core.config.MasterRepositoryDbInfo;
import oracle.odi.core.config.OdiInstanceConfig;
import oracle.odi.core.config.PoolingAttributes;
import oracle.odi.setup.JdbcProperties;
import oracle.odi.setup.RepositorySetupException;
import oracle.odi.setup.TechnologyName;
import oracle.odi.setup.AuthenticationConfiguration;
import oracle.odi.setup.IMasterRepositorySetup;
import oracle.odi.setup.IWorkRepositorySetup;

public class CreateMasterRepository {
public static void main(String[] args) {
boolean response=false;
//Master repository parameters details
String pUrl="jdbc:oracle:thin:@localhost:1521:xe";
String pDriver="oracle.jdbc.OracleDriver";
String masteruser="odi_master4";
String masterpwd="odimaster4";
String odiSupvPwd="SUNOPSIS";
String pDbaUsername="SYS AS SYSDBA";
String pDbaPassword="system";
int pMasterRepositoryId=211;
//Work repository parameter details
String pWorkUrl=pUrl;
String pWorkDriver=pDriver;
String pWorkUsername="odi_work4";
String pWorkPassword="odiwork4";
int pWorkDevRepositoryId=212;
String pWorkRepositoryName="ODI_WORKREP4";
String pWorkRepositoryPassword="odiwork4";

String Odi_User="SUPERVISOR";
//start Master repository
JdbcProperties pMasterRepositoryJdbcProperties= new JdbcProperties(pUrl, pDriver, masteruser, masterpwd);
TechnologyName pMasterTechnology = TechnologyName.ORACLE;
AuthenticationConfiguration pAuthenticationConfiguration = AuthenticationConfiguration.createStandaloneAuthenticationConfiguration(odiSupvPwd.toCharArray());
IMasterRepositorySetup masterRepositorySetup = new MasterRepositorySetupImpl();

try {
System.out.println("Master repository creation started");
long start = System.currentTimeMillis();
response = masterRepositorySetup.createMasterRepository(pMasterRepositoryJdbcProperties,pDbaUsername,pDbaPassword.toCharArray(), pMasterRepositoryId, pMasterTechnology, true,pAuthenticationConfiguration,null);
long end = System.currentTimeMillis();
long total=end-start;
if (response==true)
System.out.println("Master repository creation successful");
System.out.println("Elapsed Time in second : "+(total/1000));
} catch (RepositorySetupException e) {
//End Master repository
//Start Work repository
MasterRepositoryDbInfo masterInfo = new MasterRepositoryDbInfo(pUrl, pDriver, masteruser,masterpwd.toCharArray(), new PoolingAttributes());
OdiInstance odiInstance=OdiInstance.createInstance(new OdiInstanceConfig(masterInfo,null));
Authentication auth = odiInstance.getSecurityManager().createAuthentication(Odi_User,odiSupvPwd.toCharArray());
TechnologyName pWorkTechnology=TechnologyName.ORACLE;
IWorkRepositorySetup workRepositorySetup = new WorkRepositorySetupImpl(odiInstance);
try {
System.out.println("Work repository creation started");
long start = System.currentTimeMillis();
response = workRepositorySetup.createWorkDevRepository(pWorkUrl,pWorkDriver,pWorkUsername,pWorkPassword, pWorkDevRepositoryId,pWorkRepositoryName, pWorkRepositoryPassword,pWorkTechnology, true);
long end = System.currentTimeMillis();
long total=end-start;
if (response==true)
System.out.println("Work repository creation successful");
System.out.println("Elapsed Time in second : "+(total/1000));
} catch (RepositorySetupException e) {
//End Work repository

Before run please ensure that the path “C:\oracle\product\11.1.1\Oracle_ODI_1\oracledi.common\odi” is added to your classpath. Otherwise you will get error “Script not found”.Here is the console output in eclipse.

Let me know in case of any issues.

About Bhabani 86 Articles
Bhabani has 12 plus years of experience in Data warehousing and Analytics projects that has span across multiple domains like Travel, Banking and Financial, Betting and Gaming Industries. Solution areas he focuses on designing the data warehouse and integrating it with cloud platforms like AWS or GCP. He is also a Elite level contributor at OTN forum more than 9 years. He loves to do experiment and POC on different integration tools and services. Some of his favorite skills are Redshift, Big Query, Python, Apache Airflow, Kafka, HDFS, Map Reduce ,HIVE, Habse, Sqoop, Drill, Impala.


  1. Hello,
    Thank you for providing this link on my question on ODI forum.

    We are creating ODI repositories using SDK. But now in ODI 11_1_1_1_7; this api needs DBA user and password. We do not have that from our end user.

    Any pointers will be appreciated.

    As i mentioned in the forum: End User does not know anything about ODI. ODI is used as Embedded solution. When end user clicks on Sync (which gets data from source to target); then we create ODI repositories. End user provides only the one schema that will used for the application and not the SYS/ SYSDBA details.

    Thank you

    • Hi, I dont think you can make it because the method we are calling itself need these parameters. So it wont be possible without having dba user and password.
      If you are creating repository in different databases then it would be big problem. But if database is fixed for the end user where they will be creating the repository, better to use a fix dba user,password for them.

      I am trying to bounce the dba usernamer,password by developing a new jar file. But I am not very sure if i can be successful or not. I will let you know once this is done. The logic is that the the method we are calling, in back it is calling a method
      DriverManagerDataSource(String driverClassName, String url, String username, char[] password, ClassLoader pDriverClassLoader) and again it is calling also
      schemaVersionUtil.createRegistryTableAndEntryIfNeeded(). Under this its checking
      String query = “select count(*) from ” + this.mSchemaVersion.getRegistryViewName();
      PreparedStatement stmt = this.mConnection.prepareStatement(query);

      Here we have to do some tweak. Let me try ,Lets see up to how much i can go. Now I am searching for this package oracle.ias.version.SchemaVersion;

  2. Hi Bhabani,
    I am getting error while executing this script.
    Line Number :19
    String pUrl=”jdbc:oracle:thin:@localhost:1521:orcl”;


  3. Hi,

    I took the script provided by you and saved it as groovy script and while running it after sorting out all the class errors, finally I am getting below error, is there anything added to the classpath.

    Master repository creation started
    Caught: java.lang.NoClassDefFoundError: oracle/ias/version/SchemaVersion
    java.lang.NoClassDefFoundError: oracle/ias/version/SchemaVersion
    at oracle.odi.setup.IMasterRepositorySetup$ Source)
    at CreateMasterRepository.main(odi_repo.groovy:49)

Comments are closed.