Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: How to change shared connection metadata from java code?

  1. #1
    Join Date
    Jun 2013
    Posts
    2

    Default How to change shared connection metadata from java code?

    Is there a way to change connection metadata (db server address, user, password etc.) from java code?
    I have tried something like that, but it didn't worked for me.
    Code:
            [...]
            SharedObjects so = new SharedObjects();
            for (SharedObjectInterface soi : so.getObjectsMap().values()) {
                if (soi instanceof DatabaseMeta) {
                    DatabaseMeta dm = (DatabaseMeta) soi;
                    dm.setDBPort("1111");
                }
            }
            [...]
            Result result = job.execute();
    Even though i changed the port number (1111), it still connects to the old one.
    Where I'm wrong? Please advice.

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    I'm sure you can do what you want, but I believe you shouldn't do it the way you try.
    I can be wrong, but I would expect your for loop never to be entered.

    Why do you want to overwrite the port during runtime anyway?
    A much better way would be a configuration file.
    So long, and thanks for all the fish.

  3. #3
    Join Date
    Jun 2013
    Posts
    2

    Default

    What I'm trying to do is to use one shared connection among multiple transformations, and to change at runtime the connection parameters. How can I do that?
    Thanks!

  4. #4
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    I can see what you try to do, but I can't imagine why you want to do it.
    Do you care to explain the reason behind this?

    You can easily get the information you need from the source code, but I'm still sure there are better ways to do it.
    So long, and thanks for all the fish.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.