简体   繁体   中英

Share Database connections across transformations in pentaho kettle

I want to share database connections that I use for a transformation across other transformations.

Is it possible in Pentaho Kettle? If yes then how?

If no, is there any other workaround for the same except for manually defining all the DB connections again?

I found this solution many years ago, somewhere on the pentaho website and I still use it. For sharing database connections I use a file named shared.xml in the directory ~/.kettle (in my HOME directory). You have to restart pentaho after writing / changing your file. After that you can select the database connection by name defined in your shared.xml in you transformations.

This is an example with some basic attributes. I use it as a template.

<?xml version="1.0" encoding="UTF-8"?>
<sharedobjects>
  <connection>
    <name>name</name>
    <server>server</server> 
    <type>type</type> 
    <access>Native</access>
    <database>database</database>
    <port>1234</port>
    <username>username</username>
    <password>Encrypted ....</password>
    <servername/>
    <data_tablespace/>
    <index_tablespace/>
    <attributes>
      <attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
      <attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
      <attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
      <attribute><code>PORT_NUMBER</code><attribute>3306</attribute></attribute>
      <attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>Y</attribute></attribute>
      <attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
      <attribute><code>STREAM_RESULTS</code><attribute>Y</attribute></attribute>
      <attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
      <attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
      <attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
  </attributes>
 </connection>   </sharedobjects>

short explanation:

name = choose a name you can identify your database... 
server = localhost or IP address or FQDN
type = POSTGRESQL, MYSQL ... database type
database = the real database name used with CREATE ...
username = must be a known user to the database

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM