Adding a MySQL Data Source to TEPS using JDBC

We had a requirement to display data from a remote MySQL database on TEPS. There is absolutely no documentation on how to do this so I attempt to explain how we managed to sort this out.

1: Check if you can get to the MySQL database from the TEPS server. You can run the following PHP script if it is not giving an error the connection is working fine! Replace
the highlighted variables with your own details.

<?php

// opening DB connection

$dbhost = ‘database_hostname‘;
$dbuser = ‘database_username‘;
$dbpass = ‘database_password‘;

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die (‘Error connecting to mysql’);

$dbname = ‘database_name‘;
mysql_select_db($dbname);

?>

2: Add the MySQL data source to the TEPS datasource list. We used the following command:

/opt/IBM/ITM/bin/tacmd configurePortalServer -s DSUSER2 -p UID=database_user PWD=database_password CONNECTION_TYPE=JDBC KFWJDBCDRIVER=com.mysql.jdbc.Driver KFWDSURL=jdbc:mysql://database_hostname:3306/database_name

This will create the DSUSER2 datasource.

3: Download MySQL JDBC connection driver from http://dev.mysql.com/downloads/connector/j/

4: Add MySQL JDBC connection driver to cq.ini this will ensure that the driver is loaded.

KFW_JVM__CTJDBC__CLASSPATH=$CANDLEHOME$/$BINARCH$/$PRODUCTCODE$/lib/tepjdbc.jar:/app/mysql-connector-java-5.1.24-bin.jar:$KFW_EWAS_HOME$/derby/lib/derby.jar:$KFW_JDBC_DRIVER$

5: Restart TEPS

Once teps is restarted the new data source should show up when you try to create a custom query on TEPS. Simply enter the SQL you would like to run against the MySQL database and the data should show up on teps in table format.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.