Perl DBI->connect("DBI::Oracle:...) error
1> code:
my $dbh = DBI->connect("DBI::Oracle:host=64.181.181.186;port=1521;sid=qa17a", "ora17135", "ora17135")
or die "Couldn't connect to database:" . DBI->errstr;
2> 错误:
Can't connect to data source Oracle:host=64.181.181.186;port=1521;sid=qa17a, no database driver specified and DBI_DSN env var not set at perltest.pl line
3> 分析
a) Code中的host/port/sid都是对的,下面是我用tnsping的结果
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 64.181.181.186)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = qa17a)))
OK (0 msec)
b) 我怀疑是不是有什么特别针对perl的环境变量没设呢?
[解决办法]
配置本地网络服务名,然后在DSN中使用本地网络服务名,再试一试。
例如:
DBI::Oracle::qa17a
[解决办法]
用楼上的方法试试。--