Action: Wait a moment and try to connect a second time. Check which services are currently known by the listener by executing: lsnrctl services. Check that the SERVICE_NAME parameter in the connect descriptor of the net service name used specifies a service known by the listener.
First check the tnsnames. ora file and ensure that it points to the correct server and port. If the Forms server is on another machine, test the TNS resolve with tnsping from the command prompt. Finally, check the listener.
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.
Starting the OracleServiceXXX from the services.msc worked for me in Windows.
This really should be a comment to Brad Rippe'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 where 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.
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With