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.
Related
I got a linux server with ubuntu 16.04 and successfully installed oracle 11gR2 on it. After system boot , I could use the following code startup oracle and do a simple query:
db#dbpc:~$ sudo lsnrctl start
db#dbpc:~$ sqlplus /nolog
SQL> conn / as sysdba
SQL> startup
SQL> select * from scott.dept;
DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
However I could not login via IP , for example if I use the following command:(after start the hole services)
db#dbpc:~$ sqlplus scott/123456#192.168.1.100:1521/orcl
It will shows:
SQL*Plus: Release 11.2.0.4.0 Production on Thu Dec 31 12:58:42 2020
Copyright (c) 1982, 2013, Oracle. All rights reserved.
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Process ID: 0
Session ID: 0 Serial number: 0
Here's my setting files:
db#dbpc:/home/rogear/tools/oracle11g/product/11.2.0/dbhome_1/network/admin$ cat listener.ora
# listener.ora Network Configuration File: /home/rogear/tools/oracle11g/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.100)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /home/rogear/tools/oracle11g
db#dbpc:/home/rogear/tools/oracle11g/product/11.2.0/dbhome_1/network/admin$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /home/rogear/tools/oracle11g/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.100)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
What's wrong?
The first thing that is wrong is that Oracle is not certified nor was ever designed for Ubuntu. Ubuntu is from an entirely different branch of the linux family. Getting oracle to work at all on it is a hack, and beyond that, nothing is guaranteed.
Also note that your connection string (sqlplus scott/123456#192.168.1.100:1521/orcl) never uses your tnsnames.ora. To use your tnsnames.ora, your connection string would be:
sqlplus scott/123456#orcl
where 'orcl' is the name of the entry in tnsnames.
Third we don't know the name of the database instance. I'd want to see the output of
ls -l | grep pmon
Fourth, Oracle 11 is old and out of support, even on supported operating systems.
If you are stuck with an Ubuntu machine (the very fact of using Ubuntu tells me this is a personal pc that you are using for self-study or schoold) your best bet would be to install Oracle VirtualBox, then use that to create a VM running a recent version of Oracle Linux, and install a recent version of Orcle on that. I have an article on that, which is a bit dated now, at https://edstevensdba.wordpress.com/category/personal-test-systems/
I am using Ruby API oci8 to connect to a remote Oracle DB, got ORA 12514.
My operating system is linux, the weird thing is when I do:
tnsping <hostname:port>
I get:
TNS Ping Utility for Linux: Version 10.2.0.2.0 Production on 22-JUL-2017 14:46:28
Copyright (c) 1997, 2005 Oracle Corporation. All rights reserved.
Used parameter files:
Used HOSTNAME adapter to resolve the alias
Attempting to contact (DESCRIPTION = (CONNECTDATA = (SERVICE_NAME= my-orasvr.db)) (ADDRESS= (PROTOCOL =TCP)(HOST = 10.15.222.44)(PORT = 1521)))
OK (0 msec)
The "Used parameter files" is empty, not sure whether it does matter.
Don't have any clue, any help is appreciate~!!
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...
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):
The question is how to install ODP.NET 2.111 and ODP.NET 4.112 in the same machine side-by-side while both point to the same database server using tnsnames.ora
I need to support a legacy system based on Oracle 11.1.0. The system is using ODP.NET 2.111 to connect to oracle. There are two clients installed at:
C:\oracle\product\11.1.0\client_1
C:\oracle\product\11.1.0\client_2
The tnsnames.ora for both is something like this:
xxxx1_SERVICE=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xxxx2)(PORT = xxx3))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = xxx4)
)
)
yyyy1_SERVICE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = yyyy2 )(PORT = yyyy3))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = yyyy4)
)
)
kkkk1_SERVICE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = kkkkk2 )(PORT = kkkk3))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = kkk4)
)
)
pppp1_SERVICE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ppppp2 )(PORT = pppp3))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = pppp4)
)
)
oooo1_SERVICE = (DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ooooo2 )(PORT = oooo3))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = oooo4)
)
)
The system is up and running using the above settings. I need to develop a new system based on EntityFramework which requires me to use a newer version of Oracle.DataAccess.Dll (4.112).
I was wondering that how I could install the new client without hurting the functionality of the legacy system so both can work side by side:
Note: I did try to install the new ODP.NET over the previous client and was able to connect to database using the following connection string:
DATA
SOURCE=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=zzzzz1)(PORT=zzzzz2)))(CONNECT_DATA=(SERVICE_NAME=zzz3_SERVICE)));User
ID=\"zzzz4\";Password=\"zzzz5\";
Thats is not desirable because 1- It breaks the legacy system because it no longer can connect to Oracle due to the upgrade in ODP.NET 2- The connection string is very strange looking
I would appreciate any help,
Thanks,
Aidin
The short answer:
Note: I did try to install the new ODP.NET over the previous client
and was able to connect to database using the following connection
string...
This indicates that your new install does not have a tnsnames.ora and sqlnet.ora in /Network/Admin. If you're OK with the old client using the new ODP.net install, than you can either copy them from the old installation or you can specify a global location for all instances with the TNS_ADMIN environment variable, ie TNS_ADMIN=C:\MyOracleFilesDir
The long answer:
When you installed the new client it most likely also installed publisher policy files into the GAC that redirect references to the old Oracle.DataAccess.dll to the new version during the assembly resolution process. Oracle.DataAccess then locates the client via a parameter (DllPath) in the registry. You can override this location by setting the dllPath in your .config file:
<configuration>
<oracle.dataaccess.client>
<add key="DllPath" value="C:\yourotherpath"/>
</oracle.dataaccess.client>
</configuration>
This is generally what I do, but as I understand this more, I realize that I'm forcing a newer dll against an older client. If your goal is to leave the old client untouched, a better option may be to delete the publisher policies from the GAC (I don't think they are even installed with the full ODAC install, only ODP.net):
If you need to reinstall them they are generally found at oraclepath\odp.net\PublisherPolicy.
Another, and maybe a better long term option, is to configure the old clients to ignore the publisher policy:
http://msdn.microsoft.com/en-us/library/cf9025zt%28v=vs.80%29.aspx
Finally, I'm pretty sure the .net components for the 2.0 vs. 4.0 frameworks are separate install options during the ODP.net installation. I think you might be able to avoid this issue simply by not installing the 2.0 components. On that note you could do a similar work around by developing your new project against the 64 bit odp.net instead. Like v2.0 and v4.0, 32 bit and 64 bit also do not have any awareness of each other.