Accessing kettle internal components using JavaScript

Source: Internet
Author: User

Accessing kettle internal components using JavaScript

There are few ETL project requirements that cannot be achieved using kettle standard steps. Let's say that every record needs to be marked as information from that database, and the original database is set through the DB connection, how do I get these settings? (Type, host, port, database name, etc.)

There are no standard steps to implement in kettle, fortunately JavaScript steps can access the kettle internal components and implement the requirements above.

Access kettle internal components are _STEP_ variables, which are automatically set in each JavaScript step. It represents the JavaScript step itself, the Gettransmeta () method of the step returns the Transmeta object, representing the entire transformation, and the Transmeta object can be used to obtain information about the database connection that is defined in the transformation. The correct Transmeta object is obtained through the Finddatabase () method, returns the Databasemeta object, and other information that provides a set of methods to return the database connection.

The following code gets some information that is named "Sourcedb" database connection.

Get DB Object

var db = _step_.gettransmeta (). Finddatabase ("Sourcedb");

Ask DB object for information

var db_type = Db.getdatabasetypedesc ();

var db_host = Db.gethostname ();

var db_port = db.getdatabaseportnumberstring ();

var db_name = Db.getdatabasename ();

var db_tblspace = Db.getdatatablespace ();

var db_idxspace = Db.getindextablespace ();

var db_user = Db.getusername ();

var db_pass = Db.getpassword ();

var db_url = Db.geturl ();

var db_driver = Db.getdriverclass ();

It is to be recalled that the kettle version is constantly being updated and that its internal components may be different between versions. Therefore, a comprehensive test is required to upgrade the code that accesses kettle internal components to a new version.

Saying so much, it's better to download the sample code, which writes the database connection information to a text file in the 5.1 version of the test.

I hope you will share the discussion, your suggestion is my motivation.

Accessing kettle internal components using JavaScript

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.