DBIish
DBIish copied to clipboard
Oracle InstantClient 18 not used?
I'm moving my first setps in Oracle connectiivity thru DBIish, and I'm having troubles:
% ls -l $ORACLE_HOME/libclntsh.so
lrwxrwxrwx 1 luca luca 17 gen 21 2019 /sviluppo/oracle/instantclient_18_3/libclntsh.so -> libclntsh.so.18.1
% raku ~/tmp/test.p6
DBIish: DBDish::Oracle needs 'libclntsh.so.12.1', not found
in method handle-library-exception at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/1423FEB30CB3EB90926C353C54979CF2C7B252C8 (DBIish) line 92
in block at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/1423FEB30CB3EB90926C353C54979CF2C7B252C8 (DBIish) line 34
in any at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/1423FEB30CB3EB90926C353C54979CF2C7B252C8 (DBIish) line 34
in method setup at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/core/sources/947BDAB9F96E0E5FCCB383124F923A6BF6F8D76B (NativeCall) line 319
in method setup at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/core/sources/947BDAB9F96E0E5FCCB383124F923A6BF6F8D76B (NativeCall) line 366
in sub raku-nativecall at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/core/sources/07D7A4E6581D1C9421412E7D2A0586F9FED3D9B5 (NativeCall::Dispatcher) line 46
in method NlsCreate at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/86830BB4236CD5657DAEFEA2206AB7D14EEAADF2 (DBDish::Oracle::Native) line 338
in method connect at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/507229042771141D1CA50793B5DFBE26BB0DAE89 (DBDish::Oracle) line 86
in method connect at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/1423FEB30CB3EB90926C353C54979CF2C7B252C8 (DBIish) line 32
in sub MAIN at /home/luca/tmp/test.p6 line 11
in block <unit> at /home/luca/tmp/test.p6 line 8
Actually thrown at:
in any at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/precomp/C20680838E7F7E4A3704D367A5560087182AC812/14/1423FEB30CB3EB90926C353C54979CF2C7B252C8 line 1
in method connect at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/1423FEB30CB3EB90926C353C54979CF2C7B252C8 (DBIish) line 34
in sub MAIN at /home/luca/tmp/test.p6 line 11
in block <unit> at /home/luca/tmp/test.p6 line 8
% raku --version
Welcome to Rakudo™ v2022.03.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.03.
Why is not recognizing my 18.3 client library?
I found that, in the comments, this is explained, even if not in the documentation (should it be added?): http://docs.oracle.com/cd/E11882_01/appdev.112/e10646/oci02bas.htm#LNOCI16208: only 12.1 client can be used. I've tried to rename the lib so that matches the required name, and it seems to do something, but I cannot connect even with tnsnames.ora in place.
% raku ~/tmp/test.p6
DBDish::Oracle: Can't connect: Logon failed: 'ORA-12154: TNS:could not resolve the connect identifier specified
' (12154)
in method connect at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/507229042771141D1CA50793B5DFBE26BB0DAE89 (DBDish::Oracle) line 105
in method connect at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/1423FEB30CB3EB90926C353C54979CF2C7B252C8 (DBIish) line 32
in sub MAIN at /home/luca/tmp/test.p6 line 11
in block <unit> at /home/luca/tmp/test.p6 line 8
with tnsnames.ora
as:
% cat $ORACLE_HOME/network/tnsnames.ora
test11=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=...)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=test11))
and my Raku program as
use DBIish;
sub MAIN() {
my $connection = DBIish.connect( 'Oracle',
database => 'test11',
user => 'luca,
password => 'secret'
);
}
Any idea what am I missing here?
No idea what could be wrong on your side, but I have version 21.5 installed, which works well:
⇒ ll /opt/oracle/instantclient_21_5/libclntsh.so.*
lrwxrwxrwx 1 root root 17 Mar 4 19:08 /opt/oracle/instantclient_21_5/libclntsh.so.10.1 -> libclntsh.so.21.1*
lrwxrwxrwx 1 root root 17 Mar 4 19:08 /opt/oracle/instantclient_21_5/libclntsh.so.11.1 -> libclntsh.so.21.1*
lrwxrwxrwx 1 root root 17 Mar 4 19:08 /opt/oracle/instantclient_21_5/libclntsh.so.12.1 -> libclntsh.so.21.1*
lrwxrwxrwx 1 root root 17 Mar 4 19:08 /opt/oracle/instantclient_21_5/libclntsh.so.18.1 -> libclntsh.so.21.1*
lrwxrwxrwx 1 root root 17 Mar 4 19:08 /opt/oracle/instantclient_21_5/libclntsh.so.19.1 -> libclntsh.so.21.1*
lrwxrwxrwx 1 root root 17 Mar 4 19:08 /opt/oracle/instantclient_21_5/libclntsh.so.20.1 -> libclntsh.so.21.1*
-rwxr-xr-x 1 root root 83686960 Jan 7 15:02 /opt/oracle/instantclient_21_5/libclntsh.so.21.1*
BTW, what's your $LD_LIBRARY_PATH
is set to?
I've LD_LIBRARY_PATH
set the same as ORACLE_HOME
, and this makes my applications in Perl working. So I guess there is something wrong with the environemtn settings:
% echo $ORACLE_HOME $LD_LIBRARY_PATH
/sviluppo/oracle/instantclient_18_3 /sviluppo/oracle/instantclient_18_3
% raku tmp/test.p6
DBDish::Oracle: Can't connect: Logon failed: 'ORA-12154: TNS:could not resolve the connect identifier specified
' (12154)
in method connect at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/507229042771141D1CA50793B5DFBE26BB0DAE89 (DBDish::Oracle) line 105
in method connect at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/1423FEB30CB3EB90926C353C54979CF2C7B252C8 (DBIish) line 32
in sub MAIN at tmp/test.p6 line 14
in block <unit> at tmp/test.p6 line 11
My TNS file is:
% cat $ORACLE_HOME/network/tnsnames.ora
test11=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=myoraclehost)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=test11))
The database
argument I pass to the connect
method is the TNS entry name.
Have you set TNS_ADMIN to the directory where your tnsnames.ora file is stored?
Yes, or at least, it seems to be fine to me:
% echo $ORACLE_HOME $LD_LIBRARY_PATH $TNS_ADMIN
/sviluppo/oracle/instantclient_18_3 /sviluppo/oracle/instantclient_18_3 /sviluppo/oracle/instantclient_18_3/network/tnsnames.ora
% raku test.p6
DBDish::Oracle: Can't connect: Logon failed: 'ORA-12154: TNS:could not resolve the connect identifier specified
' (12154)
in method connect at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/507229042771141D1CA50793B5DFBE26BB0DAE89 (DBDish::Oracle) line 105
in method connect at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/1423FEB30CB3EB90926C353C54979CF2C7B252C8 (DBIish) line 32
in sub MAIN at test.p6 line 14
in block <unit> at test.p6 line 11
% cat $TNS_ADMIN
test11=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=myoraclehost)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=test11))
TNS_ADMIN should only contain the directory, not the filename.
Nothing changes:
% echo $ORACLE_HOME $LD_LIBRARY_PATH $TNS_ADMIN
/sviluppo/oracle/instantclient_18_3 /sviluppo/oracle/instantclient_18_3 /sviluppo/oracle/instantclient_18_3/network
% raku test.p6
DBDish::Oracle: Can't connect: Logon failed: 'ORA-12154: TNS:could not resolve the connect identifier specified
' (12154)
in method connect at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/507229042771141D1CA50793B5DFBE26BB0DAE89 (DBDish::Oracle) line 105
in method connect at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/1423FEB30CB3EB90926C353C54979CF2C7B252C8 (DBIish) line 32
in sub MAIN at test.p6 line 14
in block <unit> at test.p6 line 11
I forgot to mention I've already tried that before!
Does the tnsnames.ora entry work with other clients?
I've fixed some issues with the tnsnames.ora
and now I'm able to connect via sqlplus
.
But when I try to run the Raku application:
% raku test.p6
Cannot resolve caller buf-sized(Any:U); none of these signatures matches:
(Blob:D \b)
(Str:D \s)
in method Logon at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/86830BB4236CD5657DAEFEA2206AB7D14EEAADF2 (DBDish::Oracle::Native) line 363
in method connect at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/507229042771141D1CA50793B5DFBE26BB0DAE89 (DBDish::Oracle) line 97
in method connect at /home/luca/.rakubrew/versions/moar-2022.03/share/perl6/site/sources/1423FEB30CB3EB90926C353C54979CF2C7B252C8 (DBIish) line 32
in sub MAIN at test.p6 line 14
in block <unit> at test.p6 line 11
The application does only one thing:
use DBIish;
sub MAIN() {
my $connection = DBIish.connect( 'Oracle',
database => 'test11',
user => 'luca,
password => 'secret'
);
}