DBD::Oracle: load_file:The specified module could not be found - windows

It's a story as old as time itself. No, I'm not talking about the story of a man's wife running off with his best friend. I'm talking about getting DBD::Oracle to work. Although both stories have about the same amount of pain associated with them.
Let us start with the facts:
Running Windows 7 -64 bit
Running Strawberry Perl (v. 5.16.3 - 32 bit) (the reason we have 32 bit is because there is a module that is only 32 bit and we are stuck with it - don't ask)
Oracle Client (version 12.1.0 - 32 bit) successfully installed.
The bin directory of said Oracle Client has been included at the front of the PATH
the addition of the following environmental variables:
ORACLE_HOME - pointing to Oracle Client path
TNS_ADMIN -pointing to Oracle Client path
LD_LIBRARY_PATH - pointing to Oracle Client path
ORACLE_USER_ID - set to a valid oracle user in the form: user/pass#system:port\sid
ORACLE_SID - set to valid oracle sid
Successful connection of sqlplus to the desired database.
"Successful creation" of DBD::Oracle into Strawberry Perl using cpanm. Although I had to use --force because the tests failed.
An entry entered into tnsnames.ora, that I assume is correct:
nameIMadeUp.WORLD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = servername)(PORT = port#))
)
(CONNECT_DATA =
(SID = sid)
)
)
After all of that, we try to run this code (snipped for the sake of brevity):
use DBI;
use DBD::ODBC;
use Log4Perl;
#logger set up here.
my $user = "username";
my $passwd = "password";
my $DSN = "dbi:Oracle:host=servername;sid=sid;port=port#";
my $oracleDbh = DBI->connect($DSN,$user,$passwd) or $logger->logdie("$DBI::errstr\n at line:".__LINE__);
And we get this glorious error:
install_driver(Oracle) failed: Can't load 'C:/strawberry/perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle: load_file:The specified module could not be found at C:/strawberry/perl/lib/DynaLoader.pm line 190.
at (eval 84)[C:/strawberry/perl/vendor/lib/DBI.pm:770] line 3.
Compilation failed in require at (eval 84)[C:/strawberry/perl/vendor/lib/DBI.pm:770] line 3.
Perhaps a required shared library or dll isn't installed where expected
...stacktrace...
So, I have read that 'C:/strawberry/perl/site/lib/auto/DBD/Oracle/Oracle.dll' is looking for oci.dll which is causing the error. However oci.dll is in [oracle_client_path]/bin/. Theoretically, it should be able to find it.
Or is it looking for another dll? are there tools in windows or maybe even visual studio that can help here?
Or is there some magical step that I am missing?
I thank you in advance for any wise sage knowledge you put forth.

Apparently, a reboot was needed. After the reboot, connections through Perl were possible. This is here in case someone is as stupid as me. I'm going back my AS/400 now...

Related

How do I setup an ODBC connection to Oracle using FireDAC?

I can succesfully connect to Oracle through the native drivers, but cannot get an ODBC connection to work. The Oracle 11g client software is installed on my Windows 7 64 bit machine, as well as the 32-bit ODBC drivers downloaded from
Instant Client Downloads for Microsoft Windows 32-bit.
Let me first describe the succesful connections:
TNSNames.ORA contains data for an Oracle 10 installation:
# TNSNAMES.ORA Network Configuration File: C:\oracle\ora92\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
VS2003-2005-10.TimeTellBV.nl =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = VS2003-2005-10)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = Orclvs10)
)
)
I set up my TFDConnection with
DriverName := S_FD_OraId;
Params.Database := 'VS2003-2005-10';
Alternatively, I can bypass TNSNAMES.ORA by specifying directly:
DriverName := S_FD_OraId;
Params.Database := '(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = VS2012-2012.timetellbv.nl)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl12.timetellbv.nl) ))';
(As you can see, this is another Oracle server not in TNSNAMES.ORA)
Now the failing attempts through ODBC
Two 32-bit Oracle ODBC drivers are installed:
Microsoft ODBC for Oracle version 6.01.7601.19135 - I think this came with the Win7 OS
Oracle in instantclient_11_2 version 11.02.00.04 - I installed this manually from the source mentioned at the top (running as admin as suggested in the Oracle Instant Client ODBC Release Notes).
I have set up two System DSNs through these drivers but neither work.
The version 6 ODBC driver, giving it the TSNAMES.ORA entry name for 'Server':
and the version 11 Oracle driver idem:
For that second one I added another entry to TNSNAMES.ORA, since that dialog obviously suggested I had to go through that file:
VS2012-2012.TimetellBV.nl =
(DESCRIPTION=
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = VS2012-2012)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl12.timetellbv.nl)
)
)
I set up my TFDConnection with
DriverName := S_FD_ODBCId;
Params.Add('DataSource=' + lODBCName); // The ODBC DSN Name
Params.Database := lDataSection.Values[INISTRING_DATABASENAME];
Both this code and the test button in de 32-bit ODBC admin fail with error:
Unable to connect
SQLState IM003
The specified driver could not be loaded due to system error 127: cannot find procedure<br />
(Oracle in instantclient_11_2; D:\app\jan\product\11.2.0\client_1\SQORA32.dll)
That folder is where my Oracle client software is installed, it contains SQORA32.DLL (and others) and is in my system path.
I have tried all kinds of variations including/excluding domain name, database name, etc, without success.
How do I properly set up an ODBC connection to connect to Oracle, to be used in a Delphi-Tokyo 32 bit app through FireDAC?
What also did not help:
Reinstalling the Visual Studio 2013 32-bit redistributable
Copy sqora32.dll to the Windows SysWOW64 folder
Setting ORACLE_HOME environment variable to d:\app\jan\product\11.2.0\client_1\
Setting TNS_ADMIN environment variable to d:\app\jan\product\11.2.0\client_1\
Renaming sqora32.dll to SQORA32.dll
Replaced c:\windows\syswow64\mfc42.dll dated 11 March 2011 with a newer one from the Oracle home folder, dated 27 April 2011
I don't know what was wrong. I found a client installer executable (i.e. that's different from the "instant client", which has no installer, and whose reinstallation did not help either), cleaned up my VM from all Oracle stuff, ran the installer with 'administrator' selection (=all available software in the package) and that finally works. ODBC was installed as well.
The only things that need to be set for the TFDCOnnection are:
DriverName := S_FD_ODBCId;
Params.Add('DataSource=' + lODBCName);
with lODBCName being the ODBC System DSN name.
(I intended to leave this as a comment for 10K users and then delete the question, but that's not possible since I put a bounty on it earlier today. Well, maybe it serves anyone else).
I have already encountered similar issue.
I can use SQLPLUS or JDBC to connect to Oracle database, but when I try to define an ODBC connection or a .Net Linq connection, that don't work.
I have then modified my TNSNAMES.ora file and replaced SERVER-NAME by SID and suddently ODBC connection has been possible.

Error while connecting sparklyr to remote sparkR in Rstudio

I tried following command in my local RStudio session to connect to sparkR -
sc <- spark_connect(master = "spark://x.x.x.x:7077",
spark_home = "/home/hduser/spark-2.0.0-bin-hadoop2.7", version="2.0.0", config = list())
But, I am getting following error -
Error in start_shell(master = master, spark_home = spark_home, spark_version = version, :
SPARK_HOME directory '/home/hduser/spark-2.0.0-bin-hadoop2.7' not found
Any help?
Thanks in advance
may I ask you have you actually installed the spark into that folder?
Can you show the result of ls command in /home/ubuntu/ folder?
And sessionInfo() in R?
Let me please share with you how I am using the custom folder structure.
It is on Win, not Ubuntu but I guess it won't make much of the difference.
Using the most recent dev edition
If you would check on GitHub the RStudio guys are updating sparklyr almost every day fixing numerous reported bugs:
devtools::install_github("rstudio/sparklyr")
in my case only installation of sparklyr_0.4.12 has resolved problem with Spark 2.0 under Windows
Checking Spark availability
please check if version you're inquiring is available:
spark_available_versions()
You should see something like the line below, which indicates that the version you indend to use is actually available for your sparklyr package.
[13] 2.0.0 2.7 spark_install(version = "2.0.0", hadoop_version = "2.7")
Installation of Spark
Just to keep the order you may like to install spark in other location rather then home folder of RStudio cache.
options(spark.install.dir = "c:/spark")
Once you are sure the desire version is available it is time to install spark
spark_install(version = "2.0.0", hadoop_version = "2.7")
I'd check if it is install correctly (change it for shell ls if needed)
cd c:/spark
dir (in Win) | ls (in Ubuntu)
Now specify the location of the edition you want to use:
Sys.setenv(SPARK_HOME = 'C:/spark/spark-2.0.0-bin-hadoop2.7')
And finally enjoy the creation of connection:
sc <- spark_connect(master = "local")
I hope it helps.

How to install tnsping?

How do I have to install tnsping?
I tried to install oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm and I'm able to use some client commands but nog tnsping.
Oracle Instance Client does not include tsnping application. You must run "Oracle Universal Installer" and enable the option for it.
I don't' remember exactly which option you have to set, either it was "Oracle Database Utilities" or "Oracle Net"
Also see McTnsping [link broken] "a Windows stand-alone program which requires no Oracle client". It's portable and doesn't need to be installed.
Usage 1: McTnsping.exe { <tns entry> | <host>:<port> } [<count>]
<tns entry> the net service name in the tnsnames.ora file.
<host>:<port> server name or IP and port (mandatory)
<count> number of times to check target, default is 1.
If whoever will reach the place like me... This is what worked for me:
Instant client Version 12.2.0.1 + sqlplus + tnsping (copied from another server of the same version)
Directory structure and env (as in bash profile):
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=${ORACLE_BASE}/instant_client122
export PATH=$ORACLE_HOME:$PATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME #since all binaries are in $ORACLE_HOME - no bin or lib are present
export TNS_ADMIN=$ORACLE_HOME/network/admin
copy from another server to target:
'tnsping' to $ORACLE_HOME
'$ORACLE_HOME/network/mesg/tnsus.msb' to $ORACLE_HOME/network/mesg
Then put proper values to $TNS_ADMIN/tnsnames.ora and load env variables. After this it should be able to perform 'tnsping' and show proper message as a response.
Here's what I did to copy tnsping over to another machine. In my case, the oracle client is installed at C:\Oracle\product\12.1.0\client_1.
This assumes there's already an Instant Client or similar installed on the destination machine; and that the oracle path and registry keys are set.
(1) Copy tnsping.exe from the source to the destination machine, into client_1\bin.
(2) Copy the following files from client_1\bin to client_1\bin:
oraasmclnt12.dll
oracell12.dll
oraclient12.dll
oraclsce12.dll
oracommon12.dll
oracore12.dll
orageneric12.dll
orahasgen12.dll
oraldapclnt12.dll
oran12.dll
orancds12.dll
orancrypt12.dll
oranhost12.dll
oranl12.dll
oranldap12.dll
oranls12.dll
oranro12.dll
orantcp12.dll
orantns12.dll
oraocr12.dll
oraocrb12.dll
oraocrutl12.dll
oraplp12.dll
orapls12.dll
ORASLAX12.DLL
orasnls12.dll
oraunls12.dll
orauts.dll
oravsn12.dll
oraxml12.dll
orazt12.dll
oraztkg12.dll
This should be about 84.6 MB.
(3) In the client_1 on the destination machine, make a backup of the following files:
oci.dll
orannzsbb12.dll
oraons.dll
orasql12.dll
orawsec12.dll
Now on the source machine, find those files in client_1\bin and copy them to client_1\ (no bin) on the destination machine, overwriting the existing files. (Note: oci.dll is ~330 kb smaller, orasql12.dll is ~300 kb smaller. I'm not sure what's lost, hence the backup).
(4) On the destination machine, create the directory mesg in client_1\Network. Now copy the following file from the source to the destination:
client_1\Network\mesg\tnsus.msb
(5) Open up regedit. Create the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_OraClient12Home1_32bit
(From another machine, it looks like the x64 version is named HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\KEY_OraClient12Home1, but the tnsping program I'm using says it's 64 bit, so ...)
Under the key, create a string named ORACLE_HOME with the value C:\Oracle\product\12.1.0\client_1.
You should be done now ($$$ = redacted):
C:\Users\$$$>tnsping $$$
TNS Ping Utility for 64-bit Windows: Version 12.1.0.2.0 - Production on 03-APR-2
019 08:47:37
Copyright (c) 1997, 2014, Oracle. All rights reserved.
Used parameter files:
C:\Oracle\product\12.1.0\client_1\network\admin\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = $$$)(PORT = $$$))) (CONNECT_DATA = (SERVICE_NAME = $$$
$$$) (SERVER = DEDICATED)))
OK (30 msec)
Troubleshooting
Here's the process I followed, sharing for when these steps invariably fail to work on a later version.
First off, I just copied the tnsping.exe over.
I didn't haphazardly pick the above dlls, as far as I can tell everyone is required. I ran the exe, and it would popup an error, I would copy the dll over and try again:
After a few dlls, you'll run into a different kind of error:
If that happens, fire up process monitor and put a filter in for the ProcessName to contain tnsping and try to run the program again. You should see something like the following. The main thing to notice is that it tries to load (in this example) orawsec12.dll, which succeeds, but then it continues to try to load the dll looking in different paths, and then at the end it triggers werfault and the program ends. I guess it realizes there's some kind of version mismatch and keeps looking for the right version.
The missing registry key will show up like the following in process monitor (operation RegOpenKey, result NAME NOT FOUND):
If the tnsus.msb file is missing, you should see something like the following in process monitor (operation CreateFile, result NAME NOT FOUND):

Connect to Oracle database using ROracle with tnsnames.ora on Mac OS 10.10

Followup to Installation of RODBC/ROracle packages on OS X Mavericks...
First of all, I have installed ROracle on Mac OS 10.10.3 (Yosemite) using the answer provided by #joran. Additionally, using the start-up plist file to set DYLD_LIBRARY_PATH, I can run library(ROracle), and it loads just fine. However, I am unable to connect to my database with a tnsnames.ora file. I have added the TNS_ADMIN variable to the .Renviron file, which RStudio seems to pick up:
> Sys.getenv("TNS_ADMIN")
[1] "opt/oracle/instantclient_11_2/network/admin"
When I run the following, for example
con <- dbConnect(drv = dbDriver("Oracle"), dbname = "db", username = "user", password = "pw")
, I get the error
Error in .oci.Connect(.oci.drv(), username = username, password = password, :
ORA-12154: TNS:could not resolve the connect identifier specified
In addition, I have also added the TNS_ADMIN environment variables to .bash_profile, but that didn't help.
NOTE 1: I have already used the tnsnames.ora file to connect to the database with SQL Developer, so I'm fairly confident the issue is something external to the content of the file.
NOTE 2: I can in fact connect using ROracle with something like:
# see example at http://www.oralytics.com/2015/05/loading-json-data-into-oracle-using.html
host <- "localhost"
port <- 1521
service <- "pdb12c"
drv <- dbDriver("Oracle")
connect.string <- paste(
"(DESCRIPTION=",
"(ADDRESS=(PROTOCOL=tcp)(HOST=", host, ")(PORT=", port, "))",
"(CONNECT_DATA=(SERVICE_NAME=", service, ")))", sep = "")
con <- dbConnect(drv, username = "dmuser", password = "dmuser", dbname = connect.string)
I double checked my tnsnames.ora file and it's in the exact same format as connect.string, so I'm thinking it's just not actually being seen by RStudio, even though Sys.getenv("TNS_ADMIN") gives me the correct path. Alternatively, it could be that the name required by the dbname argument on Mac is different than Windows.
Any help would be greatly appreciated! Thanks!
I've seen many recommendations online for adding environment variables on Yosemite to be accessed by RStudio. The only one that has fully worked for me, at least so far, is to add all environment variables to the plist file. You can add as many variables as you want, which is described by #MortimorGoro in Setting environment variables via launchd.conf no longer works in OS X Yosemite/El Capitan/macOS Sierra?.
So my solution here was to just add TNS_ADMIN to plist!
For those of you that got here but are on Windows 7, on my workstation I have to use a TNSnames.ora file (also utilizing TNS_ADMIN environment variable)(Located in: C:\app - see 2nd screenshot), I got the following to work:
library(RODBC)
channel <- odbcConnect("PERMIT_DEV_odbc",
uid = "POWDERED_TOAST_MAN",
pwd = "dev_NONE_OF_YOUR_BEEZNEEZ",
believeNRows = FALSE)
testsql <- "select sysdate from dual;"
query <- sqlQuery(channel = channel,
query = testsql)
1 Click on the Start button (in windows 7)
2 Start typing, "odbc" and look for "set up data sources (ODBC)" or something like that.
3 Add your connection based off your TNS file.
4 there's also a "test connection" button you should use to verify connectivity!
Hope this helps!

Haskell, HDBC, ODBC, MySQL and Mac OS X

I'm trying to use Haskell (version 6.10.3) and HDBC to connect to a MySQL Database. I've chosen to do it with Haskell ODBC. I've used cabal to install HDBC (2.1.1) and HDBC-ODBC (2.1.0.0). I've downloaded and installed the MySQL ODBC driver (5.1.5). I used macports to install unixODBC (2.2.14_1). All of this on top of Mac OS X (10.5.8).
I've mostly been using the instructions on this page http://en.wikibooks.org/wiki/Haskell/Database. At around this point:
"# Add the mysql driver to odbcinst.ini file (under $ODBC_HOME/etc/) and your data source in $HOME/.odbc.ini."
It looks like the macports version of unixODBC installs everything under /opt/local/. I've put an odbcinst.ini into /opt/local/etc/ and I've created a .odbc.ini in my home directory which looks something like this (note that I've experimented with UID vs. USERNAME and PWD vs PASSWORD):
[ODBC Data Sources]
myodbc = MySQL ODBC 5.1 Driver
[ODBC]
Trace = 0
TraceAutoStop = 0
TraceFile =
TraceLibrary =
[myodbc]
Driver = /usr/local/lib/libmyodbc5.so
DATABASE = [hidden]
DESCRIPTION = [hidden]
SERVER = localhost
PORT = 3306
UID = [hidden]
PWD = [hidden]
PASSWORD = [hidden]
USER = [hidden]
And I've written and compiled this Haskell Program:
import Database.HDBC.ODBC
import Database.HDBC
import System
main = do
args <- getArgs
c <- connectODBC (args!!0)
tables <- getTables c
mapM_ putStrLn $ tables
When I try a DSN of "DSN=myodbc" it errors out with:
Database: SqlError
{seState = "[\"HY000\"]",
seNativeError = -1,
seErrorMsg = "connectODBC/sqlDriverConnect:
[\"1045: [unixODBC][MySQL][ODBC 5.1 Driver]Access
denied for user 'jamie'#'localhost' (using password: YES)\"]"}
However, when I try a DSN of "DSN=myodbc;UID=[hidden];PWD=[hidden]", it lists all the tables in the database.
This may be a unixODBC problem rather than a Haskell / HDBC / HDBC-ODBC problem. Running "isql myodbc" results in a "Bus Error". Running "isql -v myodbc" doesn't give any more information. Running isql [uid] [pwd] connects just fine.
iODBC, maintained and supported by my employer, has shipped as part of Mac OS X since Jaguar (10.2.x).
You'll be better off updating iODBC with all the latest patches (Apple tends to be a bit behind on these), than shifting to UnixODBC.
It's generally best to keep all your ODBC configuration in the default file locations for Mac OS X --
/Library/ODBC/odbc.ini
/Library/ODBC/odbcinst.ini
/Users/*/Library/ODBC/odbc.ini
/Users/*/Library/ODBC/odbcinst.ini
You can create symlinks from anywhere else you may want to have these files, e.g. --
ln -s ~/Library/ODBC/odbc.ini ~/.odbc.ini
Last, you may benefit from testing with a commercial ODBC driver for MySQL, such as one of my employer's offerings (two week free trial provided as part of download).

Resources