Creating a MySQL data source in Talend Runtime Container - 6.5

Executing Jobs

author
Talend Documentation Team
EnrichVersion
6.5
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Deployment > Deploying > Executing Jobs
EnrichPlatform
Talend Studio
To be able to retrieve data from a MySQL database table and displays the data on the console, you must have created a MySQL data source in Talend Runtime Container.

Before you begin

You must have properly installed Talend Runtime in the machine in which you want to execute your Job. For further information, search for installing Talend Runtime on Talend Help Center .

Procedure

  1. Install the MySQL JDBC driver by running the following bundle:install command in Talend Runtime Container:
    karaf@trun()> bundle:install mvn:mysql/mysql-connector-java/5.1.18
  2. Install the database connection pool by running the following bundle:install command in Talend Runtime Container:
    karaf@trun()> bundle:install -s mvn:commons-dbcp/commons-dbcp/1.4
  3. Copy the data source configuration file datasource-mysql.xml under the folder <TalendRuntimePath>/add-ons/datasources/dataservice to the folder <TalendRuntimePath>/container/deploy and then in the file update the username and password property values required to connect to your database.
    <?xml version="1.0" encoding="UTF-8"?>
    <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
        default-activation="lazy">
    
        <bean id="mysqlDataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
            <property name="url" value="jdbc:mysql://localhost:3306/test"/>
            <property name="user" value="root"/>
            <property name="password" value="talend"/>
        </bean>
    
        <bean id="dataSource" class="org.apache.commons.dbcp.datasources.SharedPoolDataSource" destroy-method="close">
            <property name="connectionPoolDataSource" ref="mysqlDataSource"/>
            <property name="maxActive" value="20"/>
            <property name="maxIdle" value="5"/>
            <property name="maxWait" value="-1"/>
        </bean>
    
        <service ref="dataSource" interface="javax.sql.DataSource">
            <service-properties>
                 <entry key="osgi.jndi.service.name" value="jdbc/sample"/>
            </service-properties>
        </service>
    </blueprint>
    
    Note: The property osgi.jndi.service.name in the data source configuration file defines the data source alias, jdbc/sample, in this example. The alias will be used in the database component to connect to the database defined in the data source configuration file when the Job is deployed in Talend Runtime.

    For more information about how to use the data source in Talend Runtime Container, see Talend ESB Container Administration Guide and Talend ESB Studio User Guide.