Monday, 10 February 2014

TNS:listener does not currently know of SID given in connect descriptor

This is a common exception we get while executing our JDBC program.
The complete StackTrace is
Lets see what may be the possible reason for this.
1.Your global_name may be different than what you have specified in your code
To see your global_name of the database,login to oracle using any username,and password
and type
SQL>       select * from global_name;
suppose it gave you XE
It should  match with jdbc code,see the name after 1521:
DriverManager.getConnection(“jdbc:oracle:oci:@localhost:1521:xe”,”system”,”manager”);
2.Your OracleServiceXE or Your OracleServiceORCL might not be running.
Open Command Prompt and type services.msc  ,press enter,you should see the following services.
For Express Edition


For Enterprise Edition







Make Sure OracleServiceXE/OracleServiceORCL is running.If not double click on it,and click on start.
3.You might have installed two Oracle databases(Express and Enterprise Edition) or
You might not have uninstalled one oracle db properly,before installing another oracle db
Open Services.msc and if you find more than 5 entries for Oracle XE,and more than 8 for Oracle Enterprise edition,then that means you have not uninstalled one oracle db properly before installing other one,or you might have installed 2 oracle at the same time
Solution:-Disable all the services of previous one,and use the services of new one.
If you have uninstalled oracle,but you can still see them in servicesYou can remove the services through registry editor.
Here is how to remove it manually by going into Registry Editor
1>Start->Run->Regedit  
2>Navigate to  HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services
3>Delete the services related folder.
Restart if needed

No comments:

Post a Comment