Oracle connection error 12514

  • Thread starter Thread starter RedEagle
  • Start date Start date
R

RedEagle

Hi All!
Since I have been reading a lot messages that helped me a lot, I am
here today to return the favour. I have been trying to connect to my
Oracle 10g server using .NET

First of all, I had to install the client part of Oracle 10g, and I
installed everything, just to be sure that I didn't miss anything (485
Megabyte, Oracle Enterprise Manager included).

Then... I wrote this code:

OracleConnection myConnection = new OracleConnection("User
Id=ANDREA;Password=ASDASD;Data Source=WIN2003");
myConnection.Open();

Of course the username ANDREA exists in Oracle, the password is the
right one and the server name is WIN2003 (if I ping WIN2003 it replies
back correctly). Before trying to connect with .NET I verified that
the Oracle Enterprise Manager (java version, not the web version)
worked fine.

BUT!!!! I get this error...
ORA-12514: the listener doesn't recognize the requested service in the
connection descriptor

(Sorry if the message doesn't match, but I am Italian and my message
was in Italian, so I had to translate it!)

I didn't have much luck with google. I tried to look for these
keywords

OracleConnection 12514

but I got no results. So I found the solution myself. The Oracle's
listener seems to identify the .NET connection using the same entry
that you can find in the file "tnsnames.ora". This is my file:

# tnsnames.ora Network Configuration File:
C:\Oracle\product\10.1.0\Client_1\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.

ORCL_WIN2003 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = WIN2003)(PORT = 1521))
)
(CONNECT_DATA =
(SID = ORCL)
(SERVER = DEDICATED)
)
)

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)

Do you see that ORCL_WIN2003? Well, THAT is Data Source parameter that
must be used in the connection string! That ORCL_WIN2003 is the result
of the SID and the host name that you enter when you add a new
database in the Oracle Enterprise Manager. So, my advice is: try to
connect usingn the Oracle Enterprise Manager first, take a look in the
"tnsnames.ora" file and then write your code.

The working version of my code is:

OracleConnection myConnection = new OracleConnection("User
Id=ANDREA;Password=ASDASD;Data Source=ORCL_WIN2003");
myConnection.Open();

Maybe it has been really easy for lot of you establish a simple
connection like this one, but it was not easy for me (I am a really
new user to Oracle), so I thought to share this experience with you
all, hoping that it might help!

Have the nicest day!
Red Eagle
 
Thank you for sharing this information RedEagle. To amplify your reach
(albeit a little bit), I am going to link this post on my blog.

- Sahil Malik [MVP]
Upcoming ADO.NET 2.0 book - http://tinyurl.com/9bync
 
Back
Top