Note
Replace <host>, <user>, and <password> with your Teradata environment credentials. If you are running Vantage Express, the default host is localhost, user is dbc, and password is dbc. You may need to expose port 1025 from your VM to the host machine — refer to your virtualization software documentation on how to forward ports.
Replace src/main/java/com/teradata/app/App.java with the following:
package com.teradata.app;
import java.sql.*;
public class App {
static final String DB_URL = "jdbc:teradata://<host>";
static final String USER = "<user>";
static final String PASS = "<password>";
static final String QUERY = "SELECT * FROM dbc.dbcinfo";
public static void main(String[] args) {
new App().query();
}
public void query() {
try (Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(QUERY)) {
while (rs.next()) {
System.out.println(String.format("setting: %s, value: %s",
rs.getString(1), rs.getString(2)));
}
} catch (SQLException e) {
throw new RuntimeException("Failed to connect or query Teradata", e);
}
}
}