<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic tMySQLOutput - dynamic database connectivity - best practice in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218948#M13950</link>
    <description>Hello,&lt;BR /&gt;The export job that i am designing supposed to do the following:&lt;BR /&gt;- connect to Oracle db&lt;BR /&gt;- get list of reports to execute in a following form:&lt;BR /&gt;&amp;nbsp; -report name&lt;BR /&gt;&amp;nbsp; -target table name&lt;BR /&gt;&amp;nbsp; -dates range (from and to)&lt;BR /&gt;- create shared connection to MySQL (tmysqlconnection object)&lt;BR /&gt;- pass values from above to a subjob.&lt;BR /&gt;- the subjob will reuse oracle (source) and mysql (target) connections from a parent job&lt;BR /&gt;The simple example worked ok, but then we have started to add real life limitations:&lt;BR /&gt;1. Outputs may be split to a different MySQL schemas (e.g. one source table have records for different customers, and in a target MySQL we have separate database for each customer, meaning that inserts need to be done to different tables in different schemas).&amp;nbsp;&lt;BR /&gt;&lt;B&gt;How can we reuse existing connection, and insert each time to different schema (for a simplicity schema name = customer name, so the data should be loaded to CUST1.PURCHASES or CUST2.PURCHASES&lt;/B&gt;&lt;BR /&gt;2. We do not want to have different job for each report type, and seeking for generic solution (a job that will take reportname as input and will take a query from repository(?), use appropriate schema and load into set of tables in a target db.&lt;BR /&gt;&lt;B&gt;What is the best practice to store metadata for each export / report if we do not want to store it in the source database?&lt;/B&gt;&lt;BR /&gt;We work with Talend Platform for DM, so any advanced options can be used.&lt;BR /&gt;Thank you in advance for your advice.&lt;BR /&gt;GB.</description>
    <pubDate>Wed, 26 Nov 2014 13:59:31 GMT</pubDate>
    <dc:creator>Gadik</dc:creator>
    <dc:date>2014-11-26T13:59:31Z</dc:date>
    <item>
      <title>tMySQLOutput - dynamic database connectivity - best practice</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218948#M13950</link>
      <description>Hello,&lt;BR /&gt;The export job that i am designing supposed to do the following:&lt;BR /&gt;- connect to Oracle db&lt;BR /&gt;- get list of reports to execute in a following form:&lt;BR /&gt;&amp;nbsp; -report name&lt;BR /&gt;&amp;nbsp; -target table name&lt;BR /&gt;&amp;nbsp; -dates range (from and to)&lt;BR /&gt;- create shared connection to MySQL (tmysqlconnection object)&lt;BR /&gt;- pass values from above to a subjob.&lt;BR /&gt;- the subjob will reuse oracle (source) and mysql (target) connections from a parent job&lt;BR /&gt;The simple example worked ok, but then we have started to add real life limitations:&lt;BR /&gt;1. Outputs may be split to a different MySQL schemas (e.g. one source table have records for different customers, and in a target MySQL we have separate database for each customer, meaning that inserts need to be done to different tables in different schemas).&amp;nbsp;&lt;BR /&gt;&lt;B&gt;How can we reuse existing connection, and insert each time to different schema (for a simplicity schema name = customer name, so the data should be loaded to CUST1.PURCHASES or CUST2.PURCHASES&lt;/B&gt;&lt;BR /&gt;2. We do not want to have different job for each report type, and seeking for generic solution (a job that will take reportname as input and will take a query from repository(?), use appropriate schema and load into set of tables in a target db.&lt;BR /&gt;&lt;B&gt;What is the best practice to store metadata for each export / report if we do not want to store it in the source database?&lt;/B&gt;&lt;BR /&gt;We work with Talend Platform for DM, so any advanced options can be used.&lt;BR /&gt;Thank you in advance for your advice.&lt;BR /&gt;GB.</description>
      <pubDate>Wed, 26 Nov 2014 13:59:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218948#M13950</guid>
      <dc:creator>Gadik</dc:creator>
      <dc:date>2014-11-26T13:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: tMySQLOutput - dynamic database connectivity - best practice</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218949#M13951</link>
      <description>So far I would say every of your requests are possible. 
&lt;BR /&gt;Please do not expect I solve it for you but here some hints: 
&lt;BR /&gt;Reading the query from a database is simple. You have to read the select statement text into a context variable and set as query simply this variable in the tOracleInout component. 
&lt;BR /&gt; 
&lt;FONT size="2"&gt;Using one connection for different databases in Oracle should work if you add the schema name in front of the table name.&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;FONT size="2"&gt;Also using different MySQL database is not a problem because you can build a job which processes one report (not a particular) report and before doing it you can setup the target database with a context variable in the tMysqlConnection.&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;BR /&gt;Now you probably get different columns for different queries. This can be achieved with the Dynamic datatype (only available in the Enterprise release). You can read everything from a query (it expects every result set column has a name matching to a column of your target table) and lead it to the target table. You can add more clear defined columns to the output schema as well (perhaps some metadata columns). 
&lt;BR /&gt;&amp;nbsp;</description>
      <pubDate>Wed, 26 Nov 2014 14:18:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218949#M13951</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-26T14:18:40Z</dc:date>
    </item>
    <item>
      <title>Re: tMySQLOutput - dynamic database connectivity - best practice</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218950#M13952</link>
      <description>Thank you for a fast and clear reply Jan,&lt;BR /&gt;The problem is that i do not want to create excessive connections, ideally i would like to have one and reuse it (e.g. if i connect not using talend, i can run statements USE CUST1; INSERT into PRODUCTS and in next subjob iteration USE CUST10; INSERT INTO PRODUCTS. Unfortunately tMySQLOutput concatenates the database's schema to the statement.&lt;BR /&gt;&amp;nbsp;</description>
      <pubDate>Wed, 26 Nov 2014 15:53:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218950#M13952</guid>
      <dc:creator>Gadik</dc:creator>
      <dc:date>2014-11-26T15:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: tMySQLOutput - dynamic database connectivity - best practice</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218951#M13953</link>
      <description>Ok we have to solve 2 issues:
&lt;BR /&gt;1. reuse database connection: To do this add to the very fist job a tMysqlConnection and setup &amp;nbsp;as shared connection.
&lt;BR /&gt;In every next job do the same (if a connection with the name already exists, it will be used instead of creating a new one).
&lt;BR /&gt;2. The tMysqlOutput uses the database name from the connection and this is at the moment always the same (wrong).
&lt;BR /&gt;The database name used by the other components is simply an entry in the globalMap. We can change it as we want. Right after every tMysqlConnection put a tJava connected with OnSubjobOk and here we change the database name as we need for this current job run:
&lt;BR /&gt;Simply add this code (I assume the connection has the name tMysqlConnection_1):
&lt;BR /&gt;globalMap.put("db_tMysqlConnection_1", context.my_current_database);
&lt;BR /&gt;We spoke about set the database name in a context variable, here you use this name.</description>
      <pubDate>Wed, 26 Nov 2014 18:13:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218951#M13953</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-26T18:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: tMySQLOutput - dynamic database connectivity - best practice</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218952#M13954</link>
      <description>Thank you Jan,&lt;BR /&gt;I am afraid that this approach is not solves the problem of having only one generic connection - changing an attribute after the connection is created will not help.&amp;nbsp;&lt;BR /&gt;In any case, i've got some weird NullPointerException trying to implement it.</description>
      <pubDate>Thu, 27 Nov 2014 11:48:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218952#M13954</guid>
      <dc:creator>Gadik</dc:creator>
      <dc:date>2014-11-27T11:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: tMySQLOutput - dynamic database connectivity - best practice</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218953#M13955</link>
      <description>Show me your job design (screenshot) and post the Exception stack trace. I am not convinced my suggestion will not work. Yes it is perhaps a bit difficult but should work.</description>
      <pubDate>Thu, 27 Nov 2014 14:29:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218953#M13955</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-27T14:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: tMySQLOutput - dynamic database connectivity - best practice</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218954#M13956</link>
      <description>You can also do the following to change the database schema at runtime.&lt;BR /&gt;&lt;PRE&gt;((java.sql.Connection)globalMap.get("conn_tMysqlConnection_1")).setCatalog("database_2");&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Jan 2015 04:03:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218954#M13956</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-01-11T04:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: tMySQLOutput - dynamic database connectivity - best practice</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218955#M13957</link>
      <description>Changing the catalog is not necessary if you use full qualified identifiers.</description>
      <pubDate>Sun, 11 Jan 2015 12:56:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMySQLOutput-dynamic-database-connectivity-best-practice/m-p/2218955#M13957</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-01-11T12:56:51Z</dc:date>
    </item>
  </channel>
</rss>

