Why does Managed ODP.Net demand SERVICE_NAME? - oracle

I am migrating a .Net 4.6.2 application from using Microsoft's System.Data.OracleClient to Oracle's own managed ODP.Net (Nuget package, version 12.2.11)for connecting to an Oracle database. I have the Oracle client installed (11gR2) and apart from changing references, using clauses, type names etc the code is pretty much the same. However, whilst my pre-migrate code connects quite happily, the post-migrate will not connect. Instead it throws an OracleException
ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA.
The tnsnames.ora file is the same, and the application's connection string is the same, and I have never before needed to specify a service name.
TnsNames.ora:
ORACLEDBSERVER2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = OracleDBServer2)(PORT = 1521))
)
(CONNECT_DATA =
(SID = orcdb10g)
(SERVER = DEDICATED)
)
Connection string:
USER ID=MATTESTNHADMIN;PASSWORD=XXXXX;DATA SOURCE=oracledbserver2
Why is it now demanding a SERVICE NAME? Even if I add a clause to the CONNECT_DATA part (SERVICE_NAME = orcdb10g) I get the same error.

I assume your program does not find the tnsnames.ora file. Unlike the old drivers the ODP.NET managed driver does not read TNS_ADMIN value from the Registy.
See this answer https://stackoverflow.com/a/28283924/3027266 to see how ODP.NET managed driver is looking for tnsnames.ora file.
Note, when you use ODP.NET managed driver then you don't have to install any further Oracle client.

Related

Connect to Oracle DB via ODBC driver

I'm trying to connect to an Oracle Database via ODBC.
This connection will allow me to connect Power BI Desktop to Oracle.
Using SQL Developer, I can managed to establish the connection, see the tables, views, etc.
Now, using Oracle Client 64-bit ODAC 12c Release 4 (12.1.0.2.4) for Windows x64, I get this tnsnames.ora file with the following configurations:
MYCONNECT=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 123.xxxx.xxx..xxx)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ORCL)
)
)
This all looks ok, but when trying to create the ODBC driver in windows, I get the following after entering the credentials:
And the error:
So, why can I establish the connection via SQL developer and not via ODBC driver?
And how can I solve this problem?
Thanks!

Oracle database 12c networking between client and server machine using TNS

I followed the instructions in the link: https://m.youtube.com/watch?v=ONGz9czAikE
And got to the point of testing a Local Net Name Configuration(8:30) when i got to the point of preforming the test it seems like the window is stuck, same thing happens when i try to connect to the server db with Sql developer there i get a socket timeout error after waiting few minutes.
I'm trying to avoid downloading the oracle client software because of a company long security verification protocol.
What am i missing? Any help will be appreciated.
From here:
Oracle 12c server cannot be accessed from remote computer using the .Net provider
Try using an external IP instead of hostname like so:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.30.50.90)(PORT = 1521))
)
)

How to connect Oracle 11G database using SQL developer from another computer in a LAN connection

I am very new in database and learning Oracle 11G. So, I do not have deep knowledge on it.
I have several computers in my lab connected via LAN. Oracle 11G is installed in computer-A(192.18.100.115). Now I want to use the database from other computers in my Lab via SQL Developer that is installed into all Computers.
Would you please explain
What I need to do in Computer-A for granting access from other Computers?
What I need to do in other computers for getting access from computer-A?
I will be grateful if any one gives me a proper solution.
What I need to do in Computer-A for granting access from other Computers?
You need to make sure the LISTENER is up and running to accept remote connection requests. Listener.ora is a SQL*Net configuration file used to configure Oracle Database Listeners. You will usually find that in ORACLE_HOME\NETWORK\ADMIN directory.
For example,
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = hostname)(PORT = 1521))
)
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ORCL)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0)
(SID_NAME = ORCL)
)
)
As you mentioned your host 192.18.100.115, you need to put it in the hostname.
What I need to do in other computers for getting access from computer-A?
You just need to install Oracle database client. If you only want to connect to the remote DB server, you could install only Instant client.
If you are using SQL Developer, then you could use:
Basic connection type
Or,
TNS connection type
In basic connection type, you need to provide all the connection details in the connection properties itself. For using TNS connection type, you need to configure the tnsnames.ora file present in ORACLE_HOME\NETWORK\ADMIN directory.

LINQPad - Connection String to my Oracle DB

I just started using LINQPad and all works great when connecting to my SQL Server DB, but now I'm trying to set up a second connection to my Oracle DB and I'm getting stuck as to how to do it.
I downloaded the IQ driver (v 2.0.8.0 - Latest) and when I go to add a new connection, I select Oracle as my DB Provider and don't know how to do the rest based upon my usual connection string looking as follows:
Data Source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = [IP Address])(PORT = [Port]))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = [Service Name])));User Id=[name];Password=[password];"
I know that you usually post what you've tried, but, believe me, I've tried filling in those text boxes every which way I could think of and keep getting errors when I click the "Test" button.
Also, one of the errors I get is:
License not valid due to the problems with dotConnect for Oracle installation - I don't think that's the only issue, but I'm sure I'll also need to fix that problem too....
Any suggestions / links to offer about what to fill in where to make this work??
THANKS!!!!!!!
I've just got this working with the latest version of LINQPad (4.55.03) Premium, and IQ (2.1.1.0), as of 2015-03-09.
In our workplace, we use the TNSNAMES.ORA file to connect to Oracle 11g using PL/SQL Developer with entries such as:
TNS_NAME =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = the-host-name)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = the-service-name)
)
)
and JDBC connection strings for ColdFusion's connection to Oracle in the format
jdbc:oracle:thin:#
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = the-host-name)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = the-service-name)
)
)
In LINQPad's Choose Data Context window, select the IQ driver and click Next...
Provider: Oracle
Connection Mode: Direct (although my workstation has both 32 and 64 bit Oracle clients installed, which PL/SQL Developer and ColdFusion use, respectively)
Server: the-host-name
User Name: your Oracle username
Password: its password
On the Advanced tab:
Additional connection string options:
SERVICE NAME=the-service-name
Clicking Test shows Connection Successful
The connection icon (a cog) in the connections pane then populated with the list of tables.
There is a build issue in the newest IQDriver release. Revert to previous version (2.0.7) and you won't see that error. Author removed latest version, so you can do that directly from LINQPad (Add connection | Select IQ | Delete Driver | Re-download IQ Driver).

SSRS: Oracle TNS:listener error?

I have a SSRS report which is using Business Object Provider. The dll has a connection with Oracle server. Whenever i run the report i keep on getting this error message:
"Oracle.DataAccess.Client.OracleException ORA-12514: TNS:listener does not currently know of service requested in connect descriptor "
Anyone knows why?
It sounds like you installed the oracle client but have not yet set up your TNS listeners.
There should be a file called "tnsnames.ora" and inside that file you need to add a new listener. If it's a windows install there might also be a network configuration GUI.
A general tnsnames.ora entry would look like this if you choose to go that way:
DBAlias =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xxx.xxx.xxx.xxx)(PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = YourDBServiceName))
)
Your tnsnames.ora file typically resides in the ORACLE_HOME/network/admin directory.
Technically speaking, you're not "creating a listener", rather, you're defining an alias for an Oracle client network connect string, which will refer to a listener somewhere.
Alternatively, you can specify an EZConnect string, if you don't want to/can't mess with tnsnames.ora entries:
"Data Source=//yourserver:1521/yourDB;User ID=theUser;Password=thePW"
You will need an entry in the sqlnet.ora file to the effect of:
NAMES.DIRECTORY_PATH = (TNSNAMES, EZCONNECT)

Resources