简体   繁体   English

在 pentaho 水壶中的转换之间共享数据库连接

[英]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? 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.多年前我在 pentaho 网站的某个地方找到了这个解决方案,我仍然在使用它。 For sharing database connections I use a file named shared.xml in the directory ~/.kettle (in my HOME directory).对于共享数据库连接,我使用目录 ~/.kettle(在我的 HOME 目录中)中名为 shared.xml 的文件。 You have to restart pentaho after writing / changing your file.写入/更改文件后,您必须重新启动 pentaho。 After that you can select the database connection by name defined in your shared.xml in you transformations.之后,您可以在转换中按 shared.xml 中定义的名称选择数据库连接。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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