Re: DBI ?

On 11/1/06, genegurevich@xxxxxxxxxxxxxxxxxxxxx <
genegurevich@xxxxxxxxxxxxxxxxxxxxx> wrote:

A developer is trying to connect to a database via DBI connect  using an
externally authenticated Oracle ID.
They claim that DBI can not connect to such an ID. Does anyone know
whether
this is true? I have not had
any experience with DBI and can't tell whether this is correct or whether
they simply don't know something.


I believe that DBI can connect anywhere sqlplus can connect.

eg.

created user 'ops$jkstill identified externally'.

From SQLPLUS:

11:47-ordevdb01:dv10:jkstill-13 > sqlplus /

SQL*Plus: Release 9.2.0.7.0 - Production on Wed Nov 1 11:47:34 2006

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.7.0 - Production
With the Partitioning option
JServer Release 9.2.0.7.0 - Production

SQL>

Again, but trying to go through sqlnet:

11:47-ordevdb01:dv10:jkstill-13 > sqlplus /@dv10

SQL*Plus: Release 9.2.0.7.0 - Production on Wed Nov 1 11:48:00 2006

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

ERROR:
ORA-01017: invalid username/password; logon denied


Enter user-name:

This would likely work if OID were setup.

From perl, on the server, with ORACLE_SID set:

11:48-ordevdb01:dv10:jkstill-13 > perl c.pl
               X
[ /home/jkstill/tmp/dbi ]


Here is the script used:

use DBI;

my $username='/';
my $password = '';

my $dbh = DBI->connect(
  'dbi:Oracle:',
  $username, $password
);

die "Connect to  $db failed \n" unless $dbh;

my $sql=q{select * from dual};
my $sth = $dbh->prepare($sql);
$sth->execute;

while( my $ary = $sth->fetchrow_arrayref ) {
  print "\t\t$ary->[0]\n";
}

$sth->finish;
$dbh->disconnect;

It the script can't connect, try the same connection from SQL*Plus.

--
Jared Still
Certifiable Oracle DBA and Part Time Perl Evangelist

Other related posts: