有人在这方面获得了成功吗?网上没有太多的参考资料,我已经用谷歌搜索了所有相关的结果。这是我的脚本:
#!/usr/bin/perl
use DBI;
use DBD::ODBC;
$user = "user";
$pw = "pw";
$ip = "192.168.1.0"
#DBI->trace(DBD::ODBC->parse_trace_flags('odbconnection'));
#my $connect_attrs = { PrintError => 0, RaiseError => 1, AutoCommit => 1 };
my $dbh = DBI->connect("dbi:ODBC:$ip", $user, $pw);
错误信息:
DBI connect('192.168.1.0','user',...) failed: (no error string) at ./teradata.pl line 13
这两行被注释掉的代码是我之前尝试连接数据库时留下的残余代码。
更新:以下是我使用DBD模块尝试连接数据库的先前努力。
#!/usr/bin/perl
use DBI;
$user = "xxxx";
$pw = "xxxx";
my $dbh = DBI->connect("dbi:Teradata:tdsn", $user, $pw);
错误:
DBI connect('tdsn','xxxx',...) failed: Unable to get host address. at ./teradata.pl line 12
第二次尝试:
#!/usr/bin/perl
use DBI;
$user = "xxxx";
$pw = "xxxx";
my $dbh = DBI->connect("dbi:Teradata:192.168.1.0", $user, $pw);
错误:
DBI connect('192.168.1.0','xxxx',...) failed: Deprecated logons are not allowed by administrator. Upgrade client software to latest version. at ./teradata.pl line 12
Third...
#!/usr/bin/perl
use DBI;
use DBD::ODBC;
$user = "xxxx";
$pw = "xxxx";
my $dbh = DBI->connect("dbi:ODBC:tdsn", $user, $pw);
.odbc.ini
[ODBC]
InstallDir = /usr/odbc
Trace = 0
TraceDll = /usr/odbc/lib/odbctrac.so
TraceFile = /home/xxxx/odbctrace.log
TraceAutoStop = 0
[ODBC Data Sources]
default = tdata.so
testdsn = tdata.so
[default]
Driver = /usr/odbc/drivers/tdata.so
Description = Default DSN is Teradata 5100
DBCName = **ip_addr**
LastUser = DLPStats
Username = xxxx
Password = xxxx
Database = MSS_TEMP
DefaultDatabase = MSS_TEMP
[tdsn]
Driver=/usr/odbc/drivers/tdata.so
Description=Teradata running Teradata V1R5.2
DBCName=**ip_addr**
LastUser=
Username=xxxx
Password=xxxx
Database=
DefaultDatabase=
错误:
DBI connect('tdsn','xxxx',...) failed: (no error string) at ./teradata.pl line 13
odbcinst.ini
[ODBC DRIVERS]
Teradata=Installed
[Teradata]
Driver=/usr/odbc/drivers/tdata.so
APILevel=CORE
ConnectFunctions=YYY
DriverODBCVer=3.51
SQLLevel=1
DBD::Teradata
模块。 - Rahul