I Found This Error when i try to Connect to Oracle TNS:protocol adapter error [duplicate] - database

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.

Related

Unable to connect to oracle database 11g R2

Till yesterday everything was working perfectly. There was an automatic windows update and after that I have been getting the error while trying to connect to my database from sqlplus:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Process ID: 0
Session ID: 0 Serial number: 0
I tried using the EM and there i got this:
Database Instance
Host
abc-PC
Port
1521
SID
mydb
Oracle Home
D:\app\abc\product\11.2.0\dbhome_1
Listener
Status
Down
Host
abc-PC
Port
1521
Name
LISTENER
Oracle Home
D:\app\abc\product\11.2.0\dbhome_1
Location
D:\app\kaos\product\11.2.0\dbhome_1\NETWORK\ADMIN
Details Although a Listener with name "LISTENER", is running on this host at port: "1521", it was not started using this target's "LISTENER.ORA" file.
CORRECTIVE ACTION: To monitor this "EM Listener Target" with its present configuration, you must stop the currently running listener process, and start it again using the Listener Parameter file: D:\app\kaos\product\11.2.0\dbhome_1\NETWORK\ADMIN/listener.ora .
Alternatively, you can update this target's "LISTENER.ORA Location" parameter with the location of the currently running Listener, which was started using: D:\app\abc\product\11.2.0\dbhome_1\NETWORK\ADMIN\listener.ora
What am I supposed to do to fix this?
Maybe update somehow remove ORACLE_SID environment variable. Check My Computer -> Properties -> Environment variables -> ORACLE_SID

Allow remote mysql access on linux (through webmin or shell)

Spec:
Ubuntu 14.04
webmin/virtualmin 1.791
I am using following code to test remote mysql database connection:
<?php
$db_host = "123.456.789";
$db_name = "database";
$db_user = "user";
$db_pass = "password";
$db_table_prefix = "prefix_";
GLOBAL $errors;
GLOBAL $successes;
$errors = array();
$successes = array();
$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_name);
GLOBAL $mysqli;
if(mysqli_connect_errno()) {
echo "Conn Error = " . mysqli_connect_error();
exit();
}
?>
I keep getting this error:
No connection could be made because the target machine actively
refused it.
Research shows this means the server is "not listening". Before I ran the above script I've already tried to allow remote mysql access through webmin gui. What I did is editting "database manage->host permissions" and make it as follows:
This was supposed to allow remote mysql access but it doesn't work. Also I read from somewhere else that to allow remote mysql access I need to edit /etc/mysql/my.cnf; I have thought that after I edit the "host permissions" in webmin this file would be changed, but it was not. On the other hand, I couldn't find the lines I was supposed to edit in my.cnf, so I am stuck here.
Any help is appreciated.
You can do this via webmin too,
Create your user account for remote access
Webmin > Servers > MySQL Database Server > User permissions
Allow the MySQL server to listen to remote requests
Webmin > Servers > MySQL Database Server > MySQL Server Configuration
MySQL server listening address - set it to any
Restart MySQL using service mysql restart or directly from webmin.
Allowing MySQL to listen to any port is not a good idea , unless you are the only one who can access that network ,
Don't leave it like this afterwards , Its better to Allow certain hosts on certain domains , like your IP , Or simply just dont listen on all ports if its not required i.e when you are finished with your session.
You can also do this via /etc/mysql/my.cnf
Just add a binding adress of your choice instead of localhost
I have got it to work, however not through webmin at all.
First I need to comment out the following line in /etc/mysql/my.cnf:
#bind-address = 127.0.0.1
I guess instead of simply commenting it out, I can also change 127.0.0.1 to my local IP address. Many google results stop here, but this is not enough. The next step is to grant the local user privileges: On remote server, I need to run the following commands:
$ mysql -u root -p
Enter password:
mysql> use mysql
mysql> GRANT ALL ON . to user#'localIP' IDENTIFIED BY
'password';
mysql> FLUSH PRIVILEGES;
Actually I have seen this when I was doing google search before I asked the question here, but I just ignored it because I thought I've done it. It turns out I not only need to grant privileges on server side but also need to do it for "local user".
Feel free to comment here if there's still something I missed out or you know how to do it throught webmin(I am still wondering what editting "host permissions" in webmin does).

How to access Oracle database over network?

I am trying to accessing my Oracle database over Network. I have Google a lot and found many solutions, but those doesn't work for me.
The problem is that, I want to access my Oracle Database from One Computer to another Computer over my Local Network.
What I did is....
I found a Solution to modify listener.ora file with
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbp.devProject.com)(PORT=1521)))
When I modify this file and tried to run and access the Database nothing will happens, and it throws an Error, the port number you have specified is used by another listener, so i have changed port Number but I am not able to access Database.
2. I have configure a new listener with the help of oracle's tool Net Manager, which made a Listener for me, but it does not make accessible database over Network.
Here Some required results.
lsnrctl status : Listener using listener name LISTENER has already been started.
Connection String : jdbc:oracle:thin:#dbp.devProject.com:4541:myDB
Database Version :
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
status shows me this.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
Alias : LISTENER
Version : TNSLSNR for 64-bit Windows: Version 11.2.0.1.0 - Production
Start Date : 14-MAY-2015 11:58:05
Uptime : 0 days 2 hr. 29 min. 50 sec
Trace Level : off
Security : ON: Local OS Authentication
SNMP : OFF
Listener Parameter File : product\11.2.0\dbhome_1\network\admin\listener.ora
Listener Log File : \listener\alert\log.xml
Listening Endpoints Summary...
1. (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
2. (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Someone please Help me.
Thanks for your Help..
Whenever you encounter this kind of errors while creating remote access for you database, follow these steps beforehand.
Create a Listener using Net Manager tool of Oracle or create it Manually.
After generating Listener, check out "listener.ora"
[Located : ORACLE_INSTALLED_DIR\product\11.2.0\dbhome_1\NETWORK\ADMIN]
file, for your entry. (is there any Entry for the Listener which you have created just before. If you found your Entry than and than do next steps otherwise do it from FIRST step.)
If you found the Entry for your Listener, Open Command Prompt and fire command lsnrctl status. This will give you all currently running Listeners List, find out the one which you created just before.
Check out the Host Name and Port Number for your Listener.
Generate the Connection String as per the details you found in lsnrctl status
Connect with Database, and You can access the Database from anywhere in your Network.
If your host name and port number is listener then You could try this option by enabling port number in firewall settings.
Opening Ports in Windows Firewall
Open the Control Panel. ...
Open Windows Firewall. ...
Click the Advanced Settings link. ...
Select "Inbound Rules". ...
Create "New Rule" under "Inbound Rules". ...
Select "Port" from the first screen of the wizard. ...
Choose TCP or UDP. ...
Enter in the port range. ...
Finish the wizard.
Create an entry in TNSNAMES.ORA file on the system from which you are trying to connect to the database. (TNSNAMES.ORA is located in ORACLE_INSTALLATION_PATH/Network/Admin/ folder)
Sample entry:
DB_HOST_NAME =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = DB_HOST_NAME)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
If you have more than one Oracle clients installed, you might need to update this in all those TNSNAMES.ORA

Connect to Oracle in remote server with .NET

HI,
In Visual Studio 2010 I select Add new connection and then I chose Oracle server. Then I choose Oracle provider for .Net. And this window comes.
I wonder what I should write in the Data Source text field if I the Oracle database is at server with name AZSSRV and IP address 172.117.17.1 ? Any help will be appreciated
After getting inspired with #Harrison's answer I finally was able to create a successful connection with Oracle Database located in a remote server. So I did exactly the way Harrison told me -created an environment variable named TNS_ADMIN and gave it the path where the TNSNAMES.ORA file is located(in my case it is :C:\app\Mikola\product\11.2.0\client_1\Network\Admin\Sample).But this on it own was not enough. I had to add some parameters to the file by opening it in a simple Text editor like Notepad.Here I'm posting the inner look of the TNSNAMES.ORA file:
OracleServerHost =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.117.17.1)(PORT = 1521))
(CONNECT_DATA =(SID = ORCL)
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
After saving and restaring VS 2010 I got "OracleServerHost" in the Data Source name drop down list.
P.S. Modifying the TNSNAMES.ORA file might not be necessary if you had already configured the file during the installation of Oracle Client.
Your entries from TNSNames.ora should appear here and you would select the one that you need to use.
Since the drop down does not seem to be working, it would indicate that VS2010 cannot find your Oracle home.
An easy solution to this is to create an environmental variable called
TNS_ADMIN
and place the path to the TNSNames.ora file you wish to you
as such
C:\app\MyDir\product\11.2.0\client_1\Network\Admin\
Close VS2010. Make the environment variable changes, then reopen, the drop down should then show you the available ora connections you may want to use.
(you can look # this thread for a bit more info: http://forums.oracle.com/forums/thread.jspa?threadID=2213359&tstart=0)
hth

How to connect to remote Oracle DB with PL/SQL Developer?

I have a database "TEST", to which I connect at address 123.45.67.89:1521.
How do I connect to it using PL/SQL Developer?
In the "database" section of the logon dialog box, enter //hostname.domain:port/database, in your case //123.45.67.89:1521/TEST - this assumes that you don't want to set up a tnsnames.ora file/entry for some reason.
Also make sure the firewall settings on your server are not blocking port 1521.
I would recommend creating a TNSNAMES.ORA file. From your Oracle Client install directory, navigate to NETWORK\ADMIN. You may already have a file called TNSNAMES.ORA, if so edit it, else create it using your favorite text editor.
Next, simply add an entry like this:
MYDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 123.45.67.89)(PORT = 1521))
(CONNECT_DATA = (SID = TEST)(SERVER = DEDICATED))
)
You can change MYDB to whatever you like, this is the identifier that applications will will use to find the database using the info from TNSNAMES.
Finally, login with MYDB as your database in PL/SQL Developer. It should automatically find the connection string in the TNSNAMES.ORA.
If that does not work, hit Help->About then click the icon with an "i" in it in the upper-lefthand corner. The fourth tab is the "TNS Names" tab, check it to confirm that it is loading the proper TNSNAMES.ORA file. If it is not, you may have multiple Oracle installations on your computer, and you will need to find the one that is in use.
The problem is not the TNS file, in PLSQL Developer, if you don't have the oracle installation, you need to provide the location of the OCI.DLL file.
In PLSQL DEV app go to Tools-Preferences-Oracle/connections-OCI Library.
In my case I put the next address C:\Oracle\InstantClient-win32-11.2.0.1.0\oci.dll.
If have Weblogic app installed, I didnt tried but if you want try to put the next location
C:\Oracle\Middleware\wlserver_10.3\server\adr.
In addition to Richard Cresswells and dpbradleys answer:
If you neither want to create a TNS name nor the '//123.45.67.89:1521/Test' input works (some configurations wont), you can put
(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 123.45.67.89)(PORT = 1521)) (CONNECT_DATA = (SID = TEST)(SERVER = DEDICATED)))
(as one line) into the 'database' section of the login dialog.
I am facing to this problem so many times till I have 32bit PL/SQL Developer and 64bit Oracle DB or Oracle Client.
The solution is:
install a 32bit client.
set PLSQL DEV-Tools-Preferencies-Oracle Home to new 32bit client Home
set PLSQL DEV-Tools-Preferencies-OCI to new 32 bit home /bin/oci.dll For example: c:\app\admin\product\11.2.0\client_1\BIN\oci.dll
Save and restart PLSQL DEV.
Edit or create a TNSNAMES.ORA file in c:\app\admin\product\11.2.0\client_1\NETWORK\admin folder like mentioned above.
Try with TNSPING in console like
C:>tnsping ORCL
If still have problem, set the TNS_ADMIN Enviroment properties value pointing to the folder where the TNSNAMES.ORA located, like: c:\app\admin\product\11.2.0\client_1\network\admin
Username : username
Password : password
Database : //123.45.67.89:1521/TEST
Connect as : Normal
this work for me and (version 13.0.6.1911 64 bit)

Resources