ERROR 704 & 12154 while connecting sqlloader to server - oracle

I have a oracle database based on a server, and I want to import the data in the tables on the server.
I am trying to use sqlloadr(sqlldr) for inserting all data in the oracle database, which is on localhost and there is no problem in this case, but the problem occurs while I try to connect a web-server(not localhost).
The command that I've used in localhost case:
sqlldr <usrname>/<password> control=table.ctl log=table.log ERRORS=25000
and following is concerning to web-server
sqlldr <usrname>/<password>#LABSERVER control=table.ctl log=table.log ERRORS=25000
where I created a tnsnames.ora as following:
LABSERVER =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(Host = <hostaddress>)(Port = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = <servicename>)
)
)
but I got this error:
SQL*Loader-704: Internal error: ulconnect:OCIServerAttache [0]
ORA-12154: TNS:could not resolve the connect identifier specified
Any idea will be appreciated

We had a similar issue and did not have privileges to modify tnsnames.ora on local, so we had to specify the service in the command line like:
sqlldr userid=username/password#\"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=myDBHost)(PORT= 1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SID=MYDBSID)))\" Control='mytable.ldr' Log='mytable.log'
thanks to https://hs2n.wordpress.com/2012/06/12/oracle-using-sqlplus-and-sqlldr-on-databases-without-tnsnames-entry/#comment-700

"where I created a tnsnames.ora which
is like following:"
That seems to mean you have posted the TNSNAMES.ORA file from the database server.
Remember you also need a TNSNAMES.ORA file on the client. Is that correctly configured too?

Basically this error is telling you that given the host, port, protocol and service_name the client could not find a listening Oracle service. Make sure that your hostname is valid (e.g., you can ping it), that the listener is listening on 1521, and that the service_name in the server database is really the name you specified. You can verify it by issuing this command in sqlplus:
SHOW PARAMETER service_names
which tells you what the database is registering itself as with the listener.

For those, like me, who found this thread.
One thing to check: file permissions on the tnsnames.ora file.
For clients on the same machine yet not part of the DBA group and with ORACLE_HOME and ORACLE_BIN set correctly subject error was reported. File permissions of the tnsnames.ora file precluded world read; as the tnsnames.ora file could not be read 704 / 12514 thrown as service name could not be resolved.
From command prompt: chmod 644 $ORACLE_HOME/network/admin/tnsnames.ora

if your password has a # character , then sqlldr utility will not work , change ur password it will work
http://www-01.ibm.com/support/docview.wss?uid=swg21347615

Related

How should I set up my sqlnet.ora and tnsnames.ora files?

I facing login issue with sqlplus login. when I m logging in using hostname, port and service name, its working fine.
sqlplus <userid>/<password>#<hostname>:<port>/<servicename>
No issues with above command. Its working as expected.
When I m trying to login with connect string,
sqplus <userid>/<password>#<connectstring>
I m getting
ORA-12154: TNS:could not resolve the connect identifier specified
I know my sqlnet.ora and tnsnames.ora are not correct, but not able to figure out where the issue is.
sqlnet.ora
SQLNET.AUTHENTICATION_SERVICES = (NTS)
NAMES.DEFAULT_DOMAIN = world
Just above two line are there in the file.
tnsnames.ora
MYTNSENTRY=
(DESCRIPTION =
....
hostname, port and service name defined in tnsnames.ora, just one entry is there.
I m executing sqlplus commands on windows platform.
Any pointers regarding this is much appreciated.
You have in your sqlnet.ora this line:
NAMES.DEFAULT_DOMAIN = world
That means '.world' is going to be appended to your connect string before looking it up in tnsnames. Either remove that line from sqlnet.ora, or append '.world' to the entry name in tnsnames.ora
mytnsentry.world =
(description...)
Agree with what #EdStevens said, and also remove the SQLNET.AUTHENTICATION_SERVICES line from sqlnet.ora. That setting is intended to help authenticate users with Windows native security (like OS authentication), but if you're not using that then it can often create problems.

Unabe to resolve cx_Oracle.DatabaseError: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

I am trying to access an oracle database on another machine. I am using:
Ubuntu Server 18.04
oracle client 12.2
python 3.6 and cx_oracle 6.4.1
I constanly get this error:
Error
File "basic_test.py", line 5, in <module>
con = cx_Oracle.connect('jalabe','jalabepass', cx_Oracle.makedsn('ipserver','port',None,'prod'))
cx_Oracle.DatabaseError: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
basic_tst.py
import cx_Oracle
# first attempt
# con = cx_Oracle.connect('jalabe/jalabepass#ipaddress/prod')
# second attempt
con = cx_Oracle.connect('jalabe','jalabepass', cx_Oracle.makedsn('ipaddress','port',None,'prod'))
print(con.version)
con.close()
tnsnames.ora
DATABASE.WORLD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ipaddress)(PORT = port))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = prod)
)
)
Other info
$ORACLE_HOME as /usr/lib/oracle/12.1/client64/lib/
File tnsnames.ora is inside /usr/lib/oracle/12.1/client64/network/admin
I have read many post without any luck. From all of the post I have read these are the ones I think are more usefull although they haven't work
ORA-12514 TNS:listener does not currently know of service requested in connect descriptor
https://stackoverflow.com/questions/46914943/can-not-connect-ora-12514-tnslistener-does-not-currently-know-of-service-reque
I am sure it might be some character somewhere.
I don't have sqlplus installed nor tnslistener. (Could it be the cause?) (I have read that tnslistener should be in the oracle server which is why i haven't installed it)
Here are a few comments and suggestions to help you correct your issue:
1) Install SQL*Plus and use it to connect to your database. You should be able to connect using the connect string 'jalabe/jalabepass#host/service_name' where 'host' is the host on which the database is found and 'service_name' is the service name of the database you want to connect to. This same connect string should work within cx_Oracle as well. You don't need to use makedsn() or tnsnames.ora (although they should also work, of course!)
2) Do not set the environment variable ORACLE_HOME when using the Instant Client.
3) On the database machine you should be able to run the command 'lsnrctl status' which will show you the status of the listener and which services it knows about. If your service isn't in the list, that's the source of the issue!
4) If you stop and restart the listener it can take a bit of time before the database will register itself with the listener. You can force that to happen more quickly by issuing the command 'alter system register' as SYSDBA in the database (or stopping/starting the database).
Hopefully that helps you out!

BizTalk WCF ORA-12154: TNS:could not resolve the connect identifier specified

I have a BizTalk 2013r2 app with a WCF-Oracle send port running under a 32bit host.
When run in my test environment it works fine. However, on my dev box I get the following error:
"ORA-12154: TNS:could not resolve the connect identifier specified"
The address set on the send port is "oracledb://test_godw_lincoln/" . My understanding is that the ip address and port should be resolved from the local tnsnames.ora file. I have a system environment variable for TNS_ADMIN set correctly:
From a command prompt, if I enter "set tns_admin" then the following is displayed:
TNS_ADMIN=C:\app\biztalk.admin\product\12.1.0\client_1\Network\Admin
If I open the file "C:\app\biztalk.admin\product\12.1.0\client_1\Network\Admin\tnsnames.ora" then I see the following entry:
test_godw_lincoln =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xx.xxx.xx.xx)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = gotest)
)
)
(I've substituted the real IP address)
If I open Sql Developer on the same dev vm then I am able to open a connection to the required database using the tnsname entry "test_godw_lincoln":
I realise that Oracle can be addressed from the adaptor without using tnsnames.ora but I understand that if ambient transactions are to be used (the app does make use of them) then the address must be via tnsnames.ora
Any suggestions as to how I can track down the cause of the problem with this particular VM?
Re question from Dmitir - the registry is empty:
Re suggestion from Felix - I am able to create the connection on the same dev server from Visual Studio server explorer:
However, if I try to connect from the "Consume Adapter Service" wizard (add generated items) then I get the ORA-12154 error:
After all this changes, have you restarted your host instances?
Try also to connect without a tnsname, with connection string in this format : host:port/database_name
This came down to a mysterious problem with the tnsnames.ora file. The suggestion from #Hichamveo helped but rather that try my bad tnsnames.ora file on a working environment, I copied the tnsnames file from an environment that worked. I found that the dev VM then started working - so I knew the problem was with the tnsnames.ora file rather than ODAC / ODP.Net assemblies.
I then spent quite some time trying to figure out exactly what was broken with the bad tnsnames file. I used file compare tools and tried a linter at: http://brantwills.github.io/tns-check/ but these showed no problems.

ORA-12560:TNS:Protocol adapter error [duplicate]

I Google[d] for this error ORA-12560: TNS:protocol adaptor error but not able to find the actual reason and how to solve this error ?
Can anyone tell me a perfect solution to solve login problem.
Go to the windows machine that hosts the Oracle database server
Go to Start -> Run -> Services.msc in Windows.
Locate OracleService < SID > (here OracleServiceORCL) and click on Start to start the oracle database service (if not already running)
Once it is up and running, from the command prompt run the following:
tnsping < tnsalias >
(tnsalias entry you can find it in tnsnames.ora file)
In my case I didn't have an OracleService (OracleServiceORCL) in Windows Services.msc as described in Bharathi's answer.
I executed this command:
C:\> ORADIM -NEW -SID ORCL
and then the OracleService called OracleServiceORCL just showed up and got started in Services.msc. Really nice.
Source: https://forums.oracle.com/forums/message.jspa?messageID=4044655#4044655
Seems like database is not up. It might be due to restarting machine and the instance is not set to autostart and it so not started munually after starting from services Screen.
Just goto Command prompt
Set Oracle SID
C:>set oracle_sid=ORCL
Now run Net start command.
C:>net start oracleserviceORCL
from command console, if you get this error you can avoid it by typing
c:\> sqlplus /nolog
then you can connect
SQL> conn user/pass #host:port/service
Add to the enviroment vars the following varibale and value to identify the place of the tnsnames.ora file:
TNS_ADMIN
C:\oracle\product\10.2.0\client_1\network\admin
In my case (for OracleExpress) the service was running, but I got this issue when trying to access the database via sqlplus without connection identifier:
sqlplus sys/mypassword as sysdba
To make it work I needed to add the connection identifier (XE for Oracle Express), so following command worked ok:
sqlplus sys/mypassword#XE as sysdba
If you still get ORA-12560, make sure you can ping the XE service. Use:
tnsping XE
And you should get OK message along with full connection string (tnsping command is located in oracle's installation dir: [oracle express installation dir]\app\oracle\product\11.2.0\server\bin). If you can not ping make sure your tnsnames.ora file is reachable for sqlplus. You might need to set TNS_ADMIN environment variable pointing to your ADMIN directory, where the file is located, for example:
TNS_ADMIN=[oracle express installation dir]\app\oracle\product\11.2.0\server\network\ADMIN
After searching alot got a simple way to solve it.
Just follow the steps.
Check status of your listener.
open command prompt and type lsnrctl status
You will get no listener.
Now open listener.ora file which is present in following directory: C:\oraclexe\app\oracle\product\11.2.0\server\network\ADMIN
Open that file and change the host parameter with you computer name
You can get your computer name by right click on My Computer and check you computer name, and replace host parameter with your computer name as follows:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = Electron-PC)(PORT = 1521)
)
)
)
So here you can observe HOST = Electron-PC, which is my computer name.
Save the listener.ora file and again return to cammand propt
3.Type the following in command prompt lsnrctl start
This will start the OracleTNSListner.
you can check it in the service by opening services tab of Task Manager. if not started automatically you can start it.
Just this much and you are ready to work again on oracle.
Best of Luck.
Quite often this means that the listener hasn't started. Check the Services panel.
On Windows (as you are) another common cause is that the ORACLE_SID is not defined in the registry. Either edit the registry or set the ORACLE_SID in a CMD box. (Because you want to run sqlplusw.exe I suggest you edit the registry.)
I have solved the problem the easy way. My oracle was running just fine in the past. After I installed MS SQL Server was when I noticed this problem. I just uninstalled MS SQL Server on my machine then the problem was gone. Make sure you restart your computer after that. Now I can connect to Oracle database through SQLPlus again. My guess is that there's some conflict between the two. Hope this helps.
Another possible solution that just worked for me...considering I was using my local login as the dba permissions.
Follow the steps to get to Services. Right click on the instance and go to 'Log On'? (might not be the name but it's one of the tabs containing permissions). Change the settings to use LOCAL.
If none the above work, then try this :
Modify the LISTENER.ora (mine is found in : oracle\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora) ==> add a custom listener that points to your database(SID), example my SID is XZ0301, so :
## Base XZ03001
SID_LIST_LISTENER_XZ03001=(SID_LIST=(SID_DESC=(ORACLE_HOME =
E:\oracle\product\11.2.0\dbhome_1)(SID_NAME= XZ03001)))
LISTENER_XZ03001=(DESCRIPTION_LIST=(ADDRESS=(PROTOCOL =
TCP)(HOST=MyComputerName)(PORT= 1521)))
DIAG_ADR_ENABLED_LISTENER_XZ03001=ON
ADR_BASE_LISTENER_XZ03001=E:\oracle
Restart your machine
For Windows 7, use the following to modify the LISTENER.ora:
- Go to Start > All Programs > Accessories
- Right click Notepad and then click Run as Administrator .
- File>open and navigate to the tnsnames.ora file.
- Make the changes then it should allow you to save
It really has worked on my machine. But instead of OracleServiceORCL I found OracleServiceXE.
Flow the flowing steps :
Edit your listener.ora and tnsnames.ora file in
$Oracle_home\product\11.2.0\client_1\NETWORK\ADMIN location
a. add listener.ora file
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
)
ADR_BASE_LISTENER = C: [here c is oralce home directory]
b. add in tnsnames.ora file
SCHEMADEV =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = dabase_ip)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = SCHEMADEV)
)
)
Open command prompt and type
sqlplus username/passowrd#oracle_connection_alias
Example : username : your_database_username
password : Your_database_password
oracle_connection_alias : SCHEMADEV for above example.
Just to add up, follow the screenshot and choose local account to start if not selected. Then start the service.
You need to tell SQLPlus which database you want to log on to. Host String needs to be either a connection string or an alias configured in your TNSNames.ora file.
ORA-12560: TNS:erro de adaptador de protocolo
set Environment Variables: ORACLE_BASE, ORACLE_HOME, ORACLE_SID
make sure your user is part of ORACLE_GROUP_NAME (Windows)
make sure the file ORACLE_HOME/network/admin/sqlnet.ora is:
SQLNET.AUTHENTICATION_SERVICES = (NTS)
(Windows) Be carefull when you add a new Oracle client: adding a new path to the PATH env. variable can mess things up. The first entry in this variable makes a difference: certify that the sqlplus executable in the ORACLE_HOME (ORACLE_HOME/bin) comes first in the PATH env. variable.
I try 2 option:
You change service OracleService in Service Tab -> Running
Login with cmd command: sqlplus user_name/pass_word#orcl12C
Note: orcle12c -> name of OracleService name run in you laptop
Below fixes can be applied to resolve TNS 12560 error
Get Latest patch for SQL*NET client software
Set $ORACLE_HOME and $PATH variable (should be accessible for System user)
Check permissions on PC client
Check $TNS_ADMIN variable
Check if network has firewall or antivirus issues
Check if windows services Run >> Services.msc has OracleXE or OracleORCL service running
Check below link in case of net tracing error:
http://dba-oracle.com/t_sql_net_tracing.htm
In my case, (ORA-12560: TNS protocol adapter error)Issue cause of database connection issue like database, user name and password.
Once you got the issue. Initially you have to check connection details, after check the oracle service and further more.
I missed some connection details, So only i got TNS protocol adapter error,
I will changed the connection details, It would be working fine.

ORA-12514 TNS:listener does not currently know of service requested in connect descriptor

We have an application running locally where we're experiencing the following error:
ORA-12514: TNS:listener does not currently know of service requested
in connect descriptor
I've tested the connection using TNSPing which resolved correctly and
I tried SQLPlus to try connecting, which failed with the same error as above. I used this syntax for SQLPlus:
sqlplus username/password#addressname[or host name]
We have verified that:
the TNS Listener on the server is running.
Oracle itself on the server is running.
We don't know of any changes that were made to this environment.
Anything else we can test?
I had this issue and the fix was to make sure in tnsnames.ora the SERVICE_NAME is a valid service name in your database. To find out valid service names, you can use the following query in oracle:
select value from v$parameter where name='service_names'
Once I updated tnsnames.ora to:
TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = *<validhost>*)(PORT = *<validport>*))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = *<servicenamefromDB>*)
)
)
then I ran:
sqlplus user#TEST
Success!
The listener is basically telling you that whatever service_name you are using isn't a valid service according to the DB.
(*I was running sqlplus from Win7 client workstation to remote DB and blame the DBAs ;) *)
I know this is an old question, but still unanswered. It took me a day of research, but I found the simplest solution, at least in my case (Oracle 11.2 on Windows 2008 R2) and wanted to share.
The error, if looked at directly, indicates that the listener does not recognize the service name. But where does it keep service names? In %ORACLE_HOME%\NETWORK\ADMIN\listener.ora
The "SID_LIST" is just that, a list of SIDs and service names paired up in a format you can copy or lookup.
I added the problem Service Name, then in Windows "Services" control panel, I did a "Restart" on the Oracle listener service. Now all is well.
For example, your listener.ora file might initially look like:
# listener.ora Network Configuration File: C:\app\oracle_user\product\12.1.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\app\oracle_user\product\12.1.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:C:\app\oracle_user\product\12.1.0\dbhome_1\bin\oraclr12.dll")
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
... And to make it recognize a service name of orcl, you might change it to:
# listener.ora Network Configuration File: C:\app\oracle_user\product\12.1.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\app\oracle_user\product\12.1.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:C:\app\oracle_user\product\12.1.0\dbhome_1\bin\oraclr12.dll")
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = C:\app\oracle_user\product\12.1.0\dbhome_1)
(SID_NAME = orcl)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
In my circumstances the error was due to the fact the listener did not have the db's service registered. I solved this by registering the services. Example:
My descriptor in tnsnames.ora:
LOCALDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = LOCALDB)
)
)
So, I proceed to register the service in the listener.ora manually:
SID_LIST_LISTENER =
(SID_DESC =
(GLOBAL_DBNAME = LOCALDB)
(ORACLE_HOME = C:\Oracle\product\11.2.0\dbhome_1)
(SID_NAME = LOCALDB)
)
Finally, restart the listener by command:
> lsnrctl stop
> lsnrctl start
Done!
I had this issue at Windows server 2008 R2 and Oracle 11g
go to Net Manager > Listener > select database services form the combox > "Global Database Name" must be same as "SID" and "Oracle Home Directory" must be correct.
If you don't have any entry for database services, create one and set correct global database , sid and oracle home.
This really should be a comment to [Brad Rippe][1]'s answer, but alas, not enough rep. That answer got me 90% of the way there. In my case, the installation and configuration of the databases put entries in the tnsnames.ora file for the databases I was running. First, I was able to connect to the database by setting the environment variables (Windows):
set ORACLE_SID=mydatabase
set ORACLE_HOME=C:\Oracle\product\11.2.0\dbhome_1
and then connecting using
sqlplus / as sysdba
Next, running the command from Brad Rippe's answer:
select value from v$parameter where name='service_names';
showed that the names didn't match exactly. The entries as created using Oracle's Database Configuration Assistant were originally:
MYDATABASE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = mylaptop.mydomain.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mydatabase.mydomain.com)
)
)
The service name from the query was just mydatabase rather than mydatabase.mydomain.com. I edited the tnsnames.ora file to just the base name without the domain portion so they looked like this:
MYDATABASE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = mylaptop.mydomain.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mydatabase)
)
)
I restarted the TNS Listener service (I often use lsnrctl stop and lsnrctl start from an administrator command window [or Windows Powershell] instead of the Services control panel, but both work.) After that, I was able to connect.
[1]: https://stackoverflow.com/users/979521/brad-rippe
Starting the OracleServiceXXX from the services.msc worked for me in Windows.
For thoses Who are using spring-boot and jdbc for connection.
You have to be careful while writing jdbcUrl in application.properties
With SID in Database connection -
source.datasource.jdbcUrl = jdbc:oracle:thin:#[HOST][:PORT]:SID
With Service name in db connection
globe.datasource.jdbcUrl = jdbc:oracle:thin:#//[HOST][:PORT]/SERVICE
This worked for me :)
For Dbeaver users: try selecting "SID" instead of "Service name" in connection settings.
I had the same problem. For me, just writing
sqlplus myusername/mypassword#localhost
did the trick, doing so makes it connect to the default service name, I guess.
This error can occur when an application makes a new connection for every database interaction or the connections are not closed properly. One of the free tools to monitor and confirm this is Oracle Sql developer (although this is not the only tool you can use to monitor DB sessions).
you can download the tool from oracle site Sql Developer
here is a screenshot of how to monitor you sessions. (if you see many sessions piling up for your application user during when you see the ORA-12514 error then it's a good indication that you may have connection pool problem).
Check to see the database is up. Log onto the server, set the ORACLE_SID environment variable to your database SID, and run SQL*Plus as a local connection.
I resolved this issue in my linux enviroment updating the IP of my machine in /etc/hosts file.
You can verify your network IP (inet end.) with:
$ifconfig
See if your IP matches with /etc/hosts file:
$cat /etc/hosts
Edit your /etc/hosts file, if nedded:
$sudo gedit /etc/hosts
Bye.
what worked for me was really simple, I just needed to initiate the service manually in the "Windows Services" (services.msc in cmd trompt).
my service name is: OracleServiceXXXXX.
I had also faced the same problem and spent 3 days to dig it out.
This happens because of your wrong TNS service entry.
First check whether you are able to connect to standby database from primary database using sql > sqlplus sys#orastand as sysdba (orastand is a standby database).
If you are not able to connect then it is a problem with the service. Correct the entry of service name in TNS file at primary end.
Check standby database the same way. Make the changes here too if required.
Make sure the log_archive_dest_2 parameter has the correct service name.
For those that may be running Oracle in a VM (like me) I saw this issue because my VM was running out of memory, which seems to have prevented OracleDB from starting up/running correctly. Increasing my VM memory and restarting fixed the issue.
Lots of answers here, but here comes a working example with code that you can copy and paste and test immediately:
For me the error 12514 was solved after specifying the correct SERVICE_NAME.
You find that on the server in the file tnsnames.ora which comes with 3 predefined service names (one of them is "XE").
I installed the Oracle Express database OracleXE112 which already comes with some preinstalled demo tables.
When you start the installer you are asked for a password. I entered "xxx" as password. (not used in production)
My server runs on the machine 192.168.1.158
On the server you must explicitely allow access for the process TNSLSNR.exe in the Windows Firewall. This process listens on port 1521.
OPTION A: For C# (.NET2 or .NET4) you can download ODAC11, from which you have to add Oracle.DataAccess.dll to your project. Additionally this DLL depends on: OraOps11w.dll, oci.dll, oraociei11.dll (130MB!), msvcr80.dll.
These DLLs must be in the same directory as the EXE or you must specify the DLL path in: HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\ODP.NET\4.112.4.0\DllPath. On 64 bit machines write additionally to HKLM\SOFTWARE\Wow6432Node\Oracle\...
OPTION B: If you have downloaded ODAC12 you need Oracle.DataAccess.dll, OraOps12w.dll, oci.dll, oraociei12.dll (160MB!), oraons.dll, msvcr100.dll. The Registry path is HKEY_LOCAL_MACHINE\SOFTWARE\Oracle\ODP.NET\4.121.2.0\DllPath
OPTION C: If you don't want huge DLL's of more than 100 MB you should download ODP.NET_Managed12.x.x.x.xxxxx.zip in which you find Oracle.ManagedDataAccess.dll which is only 4 MB and is a pure managed DLL which works in 32 bit and 64 bit processes as well and depends on no other DLL and does not require any registry entries.
The following C# code works for me without any configuration on the server side (just the default installation):
using Oracle.DataAccess.Client;
or
using Oracle.ManagedDataAccess.Client;
....
string oradb = "Data Source=(DESCRIPTION="
+ "(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.158)(PORT=1521)))"
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XE)));"
+ "User Id=SYSTEM;Password=xxx;";
using (OracleConnection conn = new OracleConnection(oradb))
{
conn.Open();
using (OracleCommand cmd = new OracleCommand())
{
cmd.Connection = conn;
cmd.CommandText = "select TABLESPACE_NAME from DBA_DATA_FILES";
using (OracleDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
listBox.Items.Add(dr["TABLESPACE_NAME"]);
}
}
}
}
If the SERVICE_NAME=XE is wrong you get error 12514. The SERVICE_NAME is optional. You can also leave it away.
In my case the database had ran out of disk space. Which caused it to not respond. Once I cleared up that issue everything worked again.
I got the same error because the remote SID specified was wrong:
> sqlplus $DATASOURCE_USERNAME/$DATASOURCE_PASSWORD#$DB_SERVER_URL/$REMOTE_SID
I queried the system database:
select * from global_name;
and found my remote SID ("XE").
Then I could connect without any problem.
In my case, round brackets around the SERVICE_NAME was missing in the tnsnames.ora file.
<DBNAME> =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL=TCP)(HOST = nupark-cnvr-ora )(PORT=1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = <DBNAME> ***CLOSING ROUND BRACKET WAS MISSING HERE***
)
)
LISTENER_<DBNAME> =
(ADDRESS = (PROTOCOL = TCP)(HOST = nupark-cnvr-ora)(PORT = 1521))
I had just to replace my connection string
from:
jdbc:oracle:thin:#localhost:1521:xe
To:
jdbc:oracle:thin:#localhost:1521:orcl
For me this was caused by using a dynamic ipadress using installation. I reinstalled Oracle using a static ipadress and then everything was fine
Restarting the VM worked for me
My issue was resolved by replacing the'SID' in URL with 'service name' and correct host.
tnslsnr is up but database is down.
For oracle novice it is not obvious that database may be down while connections are accepted.
I had to start up database manually like that
su - oracle
export ORACLE_SID=XE
sqlplus sys as sysdba
And then in sql console
startup
In my case i failed to startup but got another error message and found the source of a problem - i had to change host name and then database auto startup was functional again.
I have implemented below workaround to resolve this issue.
I have set the ORACLE_HOME using command prompt
(right click cmd.exe and Run as System administrator).
Used below command
set oracle_home="path to the oracle home"
Go to All programs --> Oracle -ora home1 --> Configuration migration tools --> Net Manager --> Listener
Select Database Services from dropdown.
Both Global database name and SID are set to the same (ORCL in my case).
Set Oracle Home Directory.
Oracle Net Manager window example from oracle documentation:
Click on File and save network configuration.
The problem was that my connection string url contained database name instead of SID.
Replacing database name with oracle database connection SID solved this problem.
To know your oracle SID's you can browse tnsnames.ora file.
XE was the actual SID, so this is how my tomcat connection string looks like now:
<Resource
name="jdbc/my_db_conn"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:#//127.0.0.1:1521/XE"
username="test_user"
password="test" />
My server version was "Oracle 11.2 Express", but solution should work on other versions too.
I had a case that I used DBMS where I had to fulfill a db connection form.
I put SID into the Database field and in the dropdown, next to the field, I had had 'Service Name' value instead of 'SID' value.
(normally I don't use Oracle database so I've not been aware of the difference)
That was the reason I got the error message.
The problem can be in the incorrect URL.
For example, I'm using Oracle database (inside VM) with Spring framework and having this issue.
I had in my application.properties file:
spring.datasource.url=jdbc:oracle:thin:#//localhost:1521/orcl12c
But the db version was defferent:
spring.datasource.url=jdbc:oracle:thin:#//localhost:1521/orclcdb
The correct URL can be found in the tnsnames.ora file (this file would be available where the Oracle server, so if you using VM, you should look for this file inside your host VM).
For example for Oracle in the VirtualBox the command to see this file is:
nano /u01/app/oracle/product/version/db_1/network/admin/tnsnames.ora
In my case for Linux environment, the oracle file at ORACLE_HOME/bin was highlighted in "Red" color with different permissions as below:
I changed the permissions of this file as below:
1) Stop Oracle -> sudo systemctl stop oracle.service
2) Change the permission of oracle file at ORACLE_HOME/bin directory as "sudo chmod 777 oracle"
3) Start Oracle -> sudo systemctl start oracle.service
Then after this change, I checked the status of listener using lsnrctl status.Here, I can see the db instances loaded successfully.
However, I can connect using sqldeveloper only, with sqlplus command line I'm getting ORA-12547: TNS Lost Contact error. So, this can a quick workaround to use sqldeveloper.
Note: Take a backup of oracle file before changing the permissions.

Resources