In this procedure, create a demo Job to validate the password encryption. In this Job,
use a tMysqlInput component to read data from a table called person
from the database and print the result on the console with tLogRow
component.
Before you begin
This example assumes that you have a MySQL database, with the following information:
- host name:
localhost
- port:
3306
- database name:
test
- user name:
root
- password:
talend
- table name:
person
- table columns:
id
: type Inter (INT), 2 characters long
name
: type String (VARCHAR), 20 characters long
sex
: type String (VARCHAR), 1 character long
Procedure
-
Create a new Job and name it
EncryptPasswordWithR0T13Demo.
-
Add a tDBInput component and a tLogRow
component to your Job.
-
Open the Contexts view, click the
[+] button to create a variable named
password, of type Password.
-
Click the Value field and type in the encryption string,
gnyraq in our example, which is the string
transformed from the real password "talend" using ROT13.
-
From the Database list of tDBInput,
select MySQL and click Apply so
that the component becomes tMysqlInput.
-
In the Basic settings view of
tMysqlInput, click the [...]
button next to the Password field, and enter the
expression to call the custom routine function in the Enter a new
password dialog box,
MyRoutine.decrypt(context.password)
in this example.
-
Configure the schema and the other parameters required to read data from your
database.
-
Save and execute the Job.
Results
You should be able to connect to the database and read data from it.