Access Teradata from a Java application

A note on connecting to Teradata from a Java application using the Teradata JDBC Driver.


Get Teradata JDBC Driver

Download the driver from here. A Teradata Downloads account is required to download.

Adding the Driver package to the project

Place the obtained terajdbc4.jar under {PROJECT_ROOT} / libs. In addition, add the following to the dependencies block of build.gradle and add it as a dependency package.

dependencies {
    implementation files('libs/terajdbc4.jar')

(* In versions prior to, it is necessary to place and add tdgssconfig.jar as well)

DataSource definition / query issuance

Set TeraDataSource which is the implementation of DataSource, get the connection and execute the query. I will. (Of course you can write using DriverManager, but it is recommended to use DataSource.)

The code I wrote roughly is below.

import com.teradata.jdbc.TeraDataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Application {

    public static void main(String[] args){

        TeraDataSource teraDataSource = new TeraDataSource();
        //Set according to the environment
        //Parameter details:

        String query = "SELECT id FROM yourdb.yourtable";

        try (Connection conn = teraDataSource.getConnection();
                Statement st = conn.createStatement();
                ResultSet rs = st.executeQuery(query)){

            while ( {
                // ResultSet#column of getXXX is 1-Note that it is based index
        } catch (SQLException e) {

You have now selected a Teradata table.


Recommended Posts

Access Teradata from a Java application
Access API.AI from Java
Run a batch file from Java
Access the in-memory data grid Apache Ignite from a Java client
Try running a Kubernetes Job from Java
[Java] Let's make a DB access library!
Access protected fields from grandchildren (Java / PHP)
If a person from Java learns PHP
Access modifier [Java]
Access MySQL on a Docker container from a local (host OS) Java program
Java 9+ application status
Access from Java using Axis2 Enterprise WSDL
GetInstance () from a @Singleton class in Groovy from Java
Run Rust from Java with JNA (Java Native Access)
To become a programmer from a Java shop
I tried hitting a Java method from ABCL
Programming beginners learn PHP from a Java perspective-variables-
Create Scala Seq from Java, make Scala Seq a Java List
[Java] Get a random value from an array
CICS-Run Java application-(1) Run a simple sample app
Ssh connect using SSHJ from a Java 6 app
It took a month from application to taking the Oracle Java SE 11 Silver
Call Java from JRuby
3. Create a database to access from the web module
How to jump from Eclipse Java to a SQL file
Call a method with a Kotlin callback block from Java
java build a triangle
From Java to Ruby !!
About Java access modifiers
Using the database (SQL Server 2014) from a Java program 2018/01/04
[Note] Create a java environment from scratch with docker
[Java] How to erase a specific character from a character string
Develop a Java application that uses Amazon SQS (Part 1)
I made a Wrapper that calls KNP from Java
File path is not recognized when executing an external command from a Java application
Call a program written in Swift from Processing (Java)
I tried running a DB access application on IKS + Db2 on IBM Cloud (6. Preparation of DB access application (java))
Create a JAVA WEB application and try OMC APM
Develop a Java application that uses Amazon SQS (Part 2)
[Unresolved] An exception occurs when an SSH connection is executed using JSch from a Java 6 application.
I tried to modernize a Java EE application with OpenShift.
Let's make a calculator application in Java ~ Display the application window
[JDBC] I tried to access the SQLite3 database from Java.
From studying programming for 2 months to releasing a web application
[Java] How to convert a character string from String type to byte type
Run R from a tomcat-powered Java process on Amazon Linux
How to store a string from ArrayList to String in Java (Personal)
Easily get an integer from a system property in Java
CData Software hands-on (getting kintone data from Java console application)
Try developing a containerized Java web application with Eclipse + Codewind
CData Software Hands-on (Get Twitter data from Java console application)
Take a look at Kotlin from an Effective Java perspective
Get a non-empty collection from an Optional stream in java
Create a simple DRUD application with Java + SpringBoot + Gradle + thymeleaf (1)
Java (WebSphere Application Server) memo [1]
Migration from Cobol to JAVA
Java starting from beginner, override
New features from Java7 to Java8
Connect from Java to PostgreSQL
[Java] Create a temporary file
What is a Java collection?