Thursday, September 6, 2012

Getting Connection information on the stream

Sometimes I need access to the database connection information inside a PDI transformation. I can use a Java Script scripting step to fetch the metadata for all database connections and put them on the stream.  Since the Java Script step is not an input step, I'll need a Generate Rows step to act as a trigger.  It will have a Limit of 1 and no fields:




The JavaScript step looks like the following:



The code is on PasteBin here.

NOTE: Make sure the Compatibility mode checkbox is not checked (see above image).

This can be extended to fetch other information such as username, tablespace, etc.  Alternatively, you can hop to Roland's transformation to grab all JDBC metadata.

2 comments:

  1. Great post Matt!

    The reader gets extra credit for doing this not just for the current transformation, but for all transformations in a folder or in a repository. You can do this using the Auto Doc step which loads TransMeta for you.

    ReplyDelete
  2. Good point! I tested with a bunch of shared connections, forgot about the local ones :)

    ReplyDelete