How To Work With Teradata Using Java?

Posted by

Teradata

Teradata is one of the leading vendor in data analytics and data warehousing applications and softwares. Especially the Teradata RDBMS is widely used across various industries like airlines, logistics, Insurance, Retail etc. Teradata DBMS is known for its ruggedness, scalability, handling complex queries to retrieve data and ofcourse for the better load balancing. Teradata can be interfaced by any CLI (Call Level Interface) , JDBC (Java Database Connectivity) and ODBC (Open Database Connectivity) clients. In this article we will look into how to query teradata in 3 steps using the widely used language Java programmatically.

Using Teradata driver for JDBC Interface

In this tutorial we are going to look at the example of a Java client interacting with Teradata using Teradata driver for JDBC Interface. The java client can be a normal java class or an applet. JDBC is an interface provided by Sun allows applications to interact with different databases irrespective of the vendor and platform. To interact with Teradata, the Teradata driver for JDBC Interface needs to be installed first by downloading it from the site. More information is provided in the below given section. The Teradata driver for JDBC Interface is nothing but a bridge built with java classes that helps to interact with JDBC Interface to work with Teradata database.

Java Client —-> Teradata JDBC Bridge —-> JDBC —-> Teradata RDBMS

Teradata driver for JDBC Interface uses a 3 tier architecture to access the Teradata database and it is the only because the database IPs will not be exposed to clients directly. So Teradata driver for JDBC Interface acts as a Teradata JDBC Gateway.

Assumptions:

  • Basic working knowledge of java and database connectivity using JDBC
  • A valid teradata database

Step I:

Install the right version of Teradata Driver for the JDBC Interface. Make sure that TERAJDBC variable is present in your environmental variables. If not set it to the folder where you have installed the driver.

eg) TERAJDBC = C:/NCR/TeraJDBC

Step II:

Please place the following files in your client classpath. The client can be a plain-java client or can be a web client. In case of web client pls place the files in the server classpath.

  • TdgssUserConfigFile.xml – configuration file for teradata
  • terajdbc4.jar – teradata drivers for JDBC Interface jars
  • tdgssjava.jar – teradata drivers for JDBC Interface jars

Step III:

Integrate the following code to connect to terradata database

/* Create the URL that is needed to connect to the Teradata RDBS */

String databaseURL = “jdbc:teradata://127.0.0.1/schema”;

/* Loads the driver */

Class.forName(“com.ncr.teradata.TeraDriver”);

/* Creates the connection to teradata database using driver for JDBC Interface */

Connection c = DriverManager.getConnection(databaseURL, databaseUserName, databaseUserpassword);

Replace 127.0.0.1 in databaseURL with teradata database servername or IP

Replace schema in databaseURL with terdata database name

Replace databaseUserName with your terdata database user name

Replace databaseUserpassword with your terdata database user password

Leave a Reply

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