Forum Discussion

FICO's avatar
FICO
Community Manager
14 years ago

Connecting to a repository using API

Connecting to a repository using API

The following works fine on a Database repository without BVS

         Hashtable<String, String> ht = getConnectionTable();          NdJdbcRepositoryConnection connection = new              NdJdbcRepositoryConnection(ht);          NdRomConnectionManager connectionMgr = NdRomFactory              .newRepositoryConnectionManager(connection);          connectionMgr.connect();          NdRomConnectionContext conContext =              connectionMgr.getConnectionContext(); Getting the following error on a Database repository with BVS Exception in thread "main" com.blazesoft.template.repository.NdRomConnectionException: Connecting to repository 'IIP BVS  Rules Dir' failed. com.blazesoft.template.repository.NdRomConnectionException: Could not get ROM configuration from repository 'IIP BVS Rul es Dir'.         at com.blazesoft.template.repository.NdRomFactory.newRepositoryConnectionManager(:551)         at com.stoneriver.iip.blaze.DecisionTableUpdate.main(DecisionTableUpdate.java:60)

Can anybody tellme what I'm missing?

5 Replies

  • FICO's avatar
    FICO
    Community Manager

    Was there a response for this or a solution?  I have the same problem with Advisor 7.0

    I can connect to a non-versioned DB repository, but not with a BVS versioned one.

    The code looks like this.  The parameters have been edited to remove any sensite content, but the ones I use can connect to a BVS repository in the DB in the IDE and from the RMA with no problem. 

    NdJdbcRepositoryConnection jdbcConnection = new NdJdbcRepositoryConnection();

    jdbcConnection.setJdbcAccessor("com.blazesoft.repository.jdbc.NdDefaultJdbcRepositoryAccessor"); jdbcConnection.setJdbcDriver("com.ibm.db2.jcc.DB2Driver"); jdbcConnection.setJdbcTable("DBSCHEMA.DBTABLE"); jdbcConnection.setJdbcUrl("jdbc:db2://HOST (http://blaze.i.lithium.com/i/smilies/16x16_smiley-tongue.gif)ORT/DB2SUBSYSTEM"); jdbcConnection.setName("BVS DB2"); jdbcConnection.setPassword("USERNAME"); jdbcConnection.setRepositoryName("BlazeVersionedRepository"); jdbcConnection.setUser("PASSWORD"); connectionMgr = NdRomFactory.newRepositoryConnectionManager(jdbcConnection); connectionMgr.connect();

    When attempting, the following error comes out:

    Exception in thread "main"

    com.blazesoft.template.repository.NdRomConnectionException: Connecting to repository 'BlazeVersionedRepository' failed.

    com.blazesoft.template.repository.NdRomConnectionException

    : Could not get ROM configuration from repository 'BlazeVersionedRepository'.

    at com.blazesoft.template.repository.NdRomFactory.WjIYoKV(:692)

    at com.blazesoft.template.repository.NdRomFactory.newRepositoryConnectionManager(:819)

    at com.blazesoft.template.repository.NdRomFactory.newRepositoryConnectionManager(:836)

    at com.blazesoft.template.repository.NdRomFactory.newRepositoryConnectionManager(:848)

    at ca.gc.customs.repository.util.blaze.RepositoryConnection.connectToRepository(

    RepositoryConnection.java:83)

    at ca.gc.customs.repository.util.blaze.RepositoryConnection.main(

    RepositoryConnection.java:43)

  • FICO's avatar
    FICO
    Community Manager

    Hi,

         When a versioning repository is used, don't connect to the versioned repository, connect to a workspace which "knows" how to find its versioned repository.  I don't know if I would even be able to find my code for this, but this is the technique.

         Tom

  • FICO's avatar
    FICO
    Community Manager

    Thanks very much for the reply Tom,

    I have to say I find the repository managment connection seems overly complicated and non-intuitive. There seems to be a number of connection files with different formats between the IDE, the API, the RMA, repositories vs. workspaces, etc.   Can I not just load one of the various files already created by the IDE and RMA and use it to connect?

    Since NdJdbcRepositoryConnection is a NdWorkspaceConnection, are there are additional properties I need to set that would indicate the workspace to connect to? When I load the properties up as a hashtable (Properties), I still get the same error.  

    Properties:

    com_blazesoft_repository_username=DBUSERID

    com_blazesoft_repository_password=DBPASSWORD com_blazesoft_repository_jdbc_url=jdbc:db2://DBHOST (http://blaze.i.lithium.com/i/smilies/16x16_smiley-very-happy.gif)BPORT/DBSUBSYSTEM com_blazesoft_repository_connectionclass=com.blazesoft.repository.jdbc.NdJdbcRepositoryConnection com_blazesoft_repository_jdbc_driver=com.ibm.db2.jcc.DB2Driver com_blazesoft_repository_jdbc_table=DBSCHEMA.DBTABLE com_blazesoft_repository_repositoryname=BlazeVersionedRepository com_blazesoft_repository_persist_credentials=true com_blazesoft_repository_jdbc_accessor=com.blazesoft.repository.jdbc.NdDefaultJdbcRepositoryAccessor

    com.blazesoft.repository_workspacefolder=c:/temp/users/workspaces

    com_blazesoft_repository_connection_name=API Private Workspace

    Code:

    try{

    Reader r =

    new FileReader("c:/temp/blazeapi/workspace.connection");

    p.load(r);

    Hashtable h = (Hashtable)p;

    NdWorkspaceConnection workspaceConnection = NdRomFactory.newWorkspaceConnection(h);

    connectionMgr = NdRomFactory.newRepositoryConnectionManager(workspaceConnection);

    }

    Error:

    Exception in thread "main"

    com.blazesoft.template.repository.NdRomConnectionException: Connecting to repository 'BlazeVersionedRepository' failed.

    com.blazesoft.template.repository.NdRomConnectionException

    : Could not get ROM configuration from repository 'BlazeVersionedRepository'.

    Any help is greatly appreciated! 

  • FICO's avatar
    FICO
    Community Manager

    FuBarre,

         Yes, the connection files in C:\Blaze\Advisor68\lib\Admin Repository\Connections can be used directly (somehow).  They are used by the command line utilities that for example cause a workspace refresh from a batch file.  The Merchandising example is a versioned repository so try digging around in there to see how that one is used.  I believe that instead of creating your own, you can read the "working" connection file from the that admin repository directory and be ready to go.

         Tom

  • FICO's avatar
    FICO
    Community Manager

    I not sure about this, but I seem to recall that we experienced a similar issue connecting to a BVS repository once. Our problem was the name we used in the connection settings, which had to match the folder name, I believe. 

    Not sure how folder name would translate to the DB version, but at least make sure you do not have different kinds of "names" for your repository. Try using what shows up as the name in your repository connection in builder as the name in your connection settings. 

    HTH, 

    Jostein