Programming codex

How To Work With Teradata Using Java?

How To Work With Teradata Using Java?



Teradata is one of the leading vendors in data analytics and data warehousing applications and software. 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 of course for 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 that 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 the 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.


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

Step I:

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


Step II:

Please place the following files in your client’s classpath. The client can be a plain-java client or can be a web client. In the 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://”;

/* Loads the driver */


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

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

Replace 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


Source by Sara P

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest
Share on whatsapp

Leave a Reply

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



Recent Posts