I have a problem where-by I cannot get Perl DBD::ODBC to use unixODBC after re-compiling and re-installing. It had been previously installed.
I had compiled DBD::ODBC to use the DataDirect ODBC Driver Manager. I now want to recompile it to use unixODBC. However, despite starting with fresh source, configuring (it picks up unixODBC), and then compiling and installing, it seems to be stuck using the DataDirect ODBC Driver Manager. I've gone as far as deleting all the files (I know of) from the Perl module folders, but the problem remains when it's reinstalled.
I'm compiling from source because the server I'm installing on doesn't have an Internet connection, so I haven't been using CPAN.
I'm using unixODBC 1.2.3 with Perl 5.8.4 (it matches the environment) on Solaris 10.
I've removed all I can find:
1. cd /usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBD/
2. sudo rm -R ODBC
3. cd /usr/perl5/site_perl/5.8.4/sun4-solaris-64int/DBD/
4. sudo rm -R ODBC
5. sudo rm ODBC.pm
6. cd /usr/perl5/5.8.4/man/man3/
7. sudo rm DBD::ODBC.3
8. sudo vi /usr/perl5/5.8.4/lib/sun4-solaris-64int/perllocal.pod
I then removed all entries for DBD::ODBC in perllocal.pod
.
I can see when I run perl Makefile.PL
that it is finding unixODBC.
Looking for odbc_config at /usr/local/unixODBC_sp64/bin/odbc_config
Found odbc_config (via /usr/local/unixODBC_sp64/bin/odbc_config) version 2.3.2
odbc_config reports --prefix=/usr/local/unixODBC_sp64
odbc_config reports --include-prefix=/usr/local/unixODBC_sp64/include
odbc_config reports --lib-prefix=/usr/local/unixODBC_sp64/lib
ODBC INC dir set to /usr/local/unixODBC_sp64/include from odbc_config
ODBC LIB dir set to /usr/local/unixODBC_sp64/lib from odbc_config
Using ODBC HOME /usr/local/unixODBC_sp64
This looks like a unixodbc type of driver manager.
Looking for odbcinst
odbcinst -j reports:
unixODBC 2.3.2
DRIVERS............: /usr/local/unixODBC_sp64/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/unixODBC_sp64/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/unixODBC_sp64/etc/ODBCDataSources
USER DATA SOURCES..: /usr/local/unixODBC_sp64/etc/odbc.ini
Here are all environment variables relating to ODBC in the environment on which I'm compiling and installing the module
LD_LIBRARY_PATH=/usr/local/unixODBC_sp64/lib:
LD_LIBRARY_PATH_64=/usr/local/unixODBC_sp64/lib:
PATH=/usr/local/unixODBC_sp64/bin:/usr/sfw/bin:/usr/ccs/bin:/opt/SUNWspro/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/bin
ODBCINI=/usr/local/unixODBC_sp64/etc/odbc.ini
ODBCHOME=/usr/local/unixODBC_sp64
When I run a test I still see an error from the DataDirect driver manager:
DBI connect('lksdjhf','ljkshdf',...) failed: [DataDirect][ODBC lib] System information file not found. Please check the ODBCINI environment variable. (SQL-IM002) at ./test_odbcdb2.pl line 19
Ignore the fact that it can't find the driver, because odbc.ini isn't populated. I'm testing with a junk connection because I want to see this same error message from unixODBC.
The Perl script I'm using for testing is below. It works with the DataDirect driver manager.
#!/usr/bin/perl -w
use DBI;
use DBD::ODBC;
use DBD::DB2::Constants;
print "Enter Data Source Name:";
my $dsn =<STDIN>;
chomp $dsn;
my $data_source = "DBI:ODBC:$dsn";
print "Enter Username:";
my $user =<STDIN>;
print "Enter password:";
my $password =<STDIN>;
chomp $user;
chomp $password;
# Connect to the db2 database using odbc
my $dbh = DBI->connect($data_source, $user, $password, {AutoCommit =>1})
or die "Can't connect to $data_source: $DBI::errstr";
$stmt = "SELECT current timestamp from sysibm.sysdummy1; ";
$sth = $dbh->prepare($stmt);
$sth->execute();
#associate variable with output columns...
$sth->bind_col(1,\$timestap);
while ($sth->fetch) {
print "The time is: $timestap\n";
}
$dbh->disconnect;
./test_odbcdb2.pl line 19
contain? – slayedbyluciferunixodbc
along withfreetds
. and I would do connectivity test usingtql
andisql
before moving on to perl. Check one of my answers from another post if it helps you: stackoverflow.com/a/21252539/1251660 – slayedbyluciferisql
that comes withunixODBC
. I'm not even getting to the point of connectivity as a result of DBD::ODBC not referencing the correct driver manager. – LokMac