PowerCenter Read Java Transformation For JDBC
PowerCenter Read Java Transformation For JDBC
The PowerCenter Read Java Transformation for JDBC connection can create a connection to a database through
JDBC and extract data from this database. It works similarly to the PowerCenter SQL Transformation and so can be
used to either extract bulk data from a JDBC database (with one single Select request) or to perform a lookup on a
JDBC database. Updates and Deletes are not supported with this transformation.
Description:
The PowerCenter Read Java Transformation can be used when you need to read data from a database which
only supports JDBC. This transformation has input ports for the JDBC connection itself (JDBC Driver Name,
Connection Parameter, User, Password) as well as input ports for the SQL Statement that you want to pass to the
database. If needed there are also input ports to pass parameters used i.e. in a where clause. Any valid SQL
Statement that is supported by the JDBC driver can be passed to the transformation. The PowerCenter Read Java
Transformation for JDBC works a bit similarly to the PowerCenter SQL Transformation.
This java transformation supports up to 30 columns as output ports, which are filled with the results of the SQL
Statement (select * from). It is an active transformation, which can returns several output rows for each incoming
row.
In addition there is a pass-through port that can be used if needed, to pass-through data, as the java
transformation is an active transformation.
The PowerCenter Read Java Transformation does not cache data like a PowerCenter Lookup transformation. Each
incoming row will send an SQL statement to the underlying database.
Demonstration:
Lets assume there is a JDBC table called customer (in a mySQL database), which has the following columns:
customer_id, first_name, last_name, city.
Customer_id is the primary key.
There is a flat file containing customer records, including customer_id and you want to create a lookup on the JDBC
table to get the first name, last name and city.
Create a mapping with the Flat File as source, an empty Expression Transformation and a Read java
transformation for JDBC:
The output ports outColumn1 to outColumn4 are linked to the target transformation. The result
from the SQL statement is returning
Customer_id in outColumn1
First_name in outColumn2
Last_name in outColumn3
City in outColumn4
The other outColumnx ports are empty
Installation :
Import the Java Transformation into your PowerCenter repository by using the import objects functionality (either
in the Designer or in Repository Manager).
Configuration :
In order to make the JDBC Java Transformation work, you will need to install the JDBC Driver from the
corresponding database on the server where PowerCenter has been installed. In addition you will need to add the
path and the JDBC jar file name to the classpath of the PowerCenter integration service :
For instance, if you use PowerCenter 9.x on Windows and want to connect to MySQL, add
C:\Program Files\MySQL\JDBC\mysql-connector-java-5.1.13\mysql-connector-java-5.1.13-bin.jar to the classpath
of the integration service (Administration Console -> Integration Service -> Processes -> Edit -> Java SDK Classpath)
Define how many inSQLParamx-ports are filled (see hereunder for the description of the
inSQLParamx ports). If no inSQLParam port is filled, define inNbrinSQLParam = 0.
inSQLParamx optional
A maximum of 6 SQL input parameters can be defined. These ports can be used i.e. to define
a where clause containing value that comes from the source definition and changes for
each request.
Output Ports
o outColumnx
Contains the result of the select statements. A maximum of 30 columns can be returned. If
you have a table with more columns, you will need to modify the java code. If the SQL
statement returns 6 columns, only the first 6 ports will be filled (outColumn1 outColumn6).
If no row is returned by the SQL Statement, no row will come out of the java transformation.
In/Output Port
o InOutPassthroughPort
The Java transformation is active. If you need it, you can pass data through the
transformation by using this port
Other details
- If you use the PowerCenter Read Java Transformation for JDBC as a lookup, it will not cache the data in
memory. Each incoming row will send an SQL statement (select) to the database
- If you want to read all the data from a JDBC database (as you would do with a source definition), you can
define in your mapping a dummy source definition which generates only one row, so that the java
transformation only receives one input row and then send the SQL request to the database and returns all
selected rows.
o
Feel free to customize the java source code if needed, for example if you need more input ports inSQLParam or
more output ports outColumn.