I actually figured out how to do so with Trino & Teradata. I felt like the documentation was very specialized. And unfortunately, I found that "one size doesn't fit all." So, I'm posting what I did - so others can learn from it.
I ran from Windows - so these are the windows steps for Teradata
From a windows command line - one would run the following:
c:\jars>java -Ddbd.port=12345 ^
+
-Dlog4j.configurationFile="C:\Work\Programming\javaProgrammingLog\jdb
+cAndPerl\DBD-JDBC-0.72.tar\DBD-JDBC-0.72\server\log4j2.properties" ^
+
-cp "C:\jars\terajdbc4.jar;C:\jars\tdgssconfig.jar;C:\jars\dbd_jdbc.j
+ar;C:\jars\log4j-api-2.17.1.jar;C:\jars\log4j-core-2.17.1.jar" ^
+
com.vizdom.dbd.jdbc.Server
Important Notes, you'll need to make sure you place your jar files in your respective folder. In my case, I placed them in c:\jars. Also, TeradataJDBC for me, worked with 17.2 - due to SSL restrictions
Step two, running the perl script
use strict;
use warnings;
use DBI;
# Credentials
my $user = "!NEDVFCollections";
my $password = "XXXXXX"; # Use the password from your DSN config
my $url = "jdbc:teradata://172.28.130.20/";
my $dsn = "dbi:JDBC:hostname=localhost;port=12345;url=$url"; # Adjus
+t port to match your Java proxy
# JDBC connection properties
my $conn_attrs = {
'USER' => $user,
'PASSWORD' => $password,
'LOGMECH' => 'LDAP',
'DBS_PORT' => '1025',
'TMODE' => 'tera'
};
# Connect
my $dbh = DBI->connect(
$dsn,
undef, undef,
{
RaiseError => 1,
jdbc_properties => $conn_attrs,
}
) or die "Connection failed: $DBI::errstr";
print "Connected to Teradata!\n";
# Example query — update to your actual table/schema
my $sql = "SELECT date,user;";
my $sth = $dbh->prepare($sql);
$sth->execute();
# Print column names
my @columns = @{$sth->{NAME_lc}};
print join(" | ", @columns), "\n";
# Print each row
while (my @row = $sth->fetchrow_array) {
my @safe_row = map { defined($_) ? $_ : '' } @row;
print join(" | ", @safe_row), "\n";
}
$sth->finish();
$dbh->disconnect();
That is how to run a Teradata perl script with Perl DBD JDBC over a Java server on windows
Cheers and happy coding
|