I am connecting to oracle database through asp.net. My code is running well on server machine but when I try to run it on local machine I am getting TNS error.
My connection Strings are :
<add name="oraclebldb" connectionString="DataSource=SKM.SMEBANK.ORG;Persist Security Info=True;User ID=bldb;Password=bldb;Unicode=True" providerName="System.Data.OracleClient"/>
<add name="OraConnectionString" connectionString="Data Source=skm;Persist Security Info=True;User ID=bldb;Password=bldb;Unicode=True" providerName="System.Data.OracleClient"/>
There must be tnsname.ora file in your local machine where you must be having oracle client installed.
go to
localdrive:\oracle\product\oracle version\client_1\Network\admin
Note: localdrive must b C or D based on location given at the time of installation
or
go to command prompt and type path which will give you the oracle home directory path of your local machine.
See below definition for your reference
mydb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myserver )(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = mydb)
)
)
Related
I am doing java database connection through oracle database and I am facing ORA-12505 exception. I have checked my Oracle services they are running properly.
Let's say you have following Configuration in TNSName.ORA
FRO =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = blue.xyz.com)(PORT = 1521))
)
(CONNECT_DATA =
(SID = servername)
(SERVER = DEDICATED)
)
)
Your connection string should look something like this
<add name="abc" connectionString="Data Source=FRO;Persist Security Info=True;User ID=def;Password=def;Unicode=True" providerName="System.Data.OracleClient" />
I'm looking at a web application that's using JDBC Connection to connect to Oracle 11g database (11.2.0). The application works without any issues for some time (about an hour) and then I get:
java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
I tried restarting Oracle and the Oracle services OracleServiceXE and OracleXETNSListener but the error won't go way. It only goes away after I restart my machine.
I've not changed any database parameters in my Tomcat or Oracle.
Here's my tnsnames.ora
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
Here's my configuration for JDBC:
String serverName = "localhost";
String portNumber = "1521";
String sid = "xe";
String url = "jdbc:oracle:thin:#" + serverName + ":" + portNumber + ":" + sid;
String username = "xxx";
String password = "yyy";
When "XE" is working properly, if I check lsnrctl status, I can see
Service "XEXDB" has 1 instance(s).
Instance "xe", status READY, has 1 handler(s) for this service...
Service "xe" has 1 instance(s).
Instance "xe", status READY, has 1 handler(s) for this service...
The command completed successfully
Once I get the exception, I do not see instance "xe" when I check lsnrctl status.
I would like to know why I'm getting this exception after some time and how to fix that. If not, how can I get around it without restarting my machine? Thanks.
Database URL should be as shown below.
// Create DataSource and connect to the local database
ods = new OracleDataSource();
ods.setURL("jdbc:oracle:thin:#//localhost:5221/orcl");
ods.setUser("HR");
ods.setPassword("hr");
conn = ods.getConnection();
Recommendation is to use the long form of connection URL as shown here.
jdbc:oracle:thin:#(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=myhost-vip)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=myorcldbservicename)))
Also, to verify if the connection URL is correctly formed, get a connection from the SQL developer using the below and test it out.
sqlplus hr/hr#"(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=myhost-vip)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=myorcldbservicename)))"
I've been trying to move the database from an application to another server without success.
I'm getting the following error message when opening the web application:
"Login failed. The login is from an untrusted domain and cannot be used with Windows authentication."
The user is a domain user configured as identity in the app pool and also has full access rights on the SQL Server (I can access the DB remotely over SQL Server Management Studio).
I tried the following:
enabled the Do not require Kerberos preauthentication option in AD
added the SQL account to "Access this computer from network" Policy under Local Security Policy -> Local Policies -> User Rights Assignment -> Access this computer from network"
Added the entry "127.0.0.1 localhost" to local hosts file
The domain user is local admin on the web and database server.
Web.Config / App Settings:
<appSettings>
<add key="DBServer" value="remoteSQLDBHostName" /> -- previous: value="."
<add key="DBName" value="WebDB" />
<add key="DBProvider" value="System.Data.SqlClient" />
<add key="DBMetadataBase" value="res://*/{0}.csdl|res://*/{0}.ssdl|res://*/{0}.msl" />
</appSettings>
The connection string is build dynamically in the application (sample snippet):
var sqlBuilder = new SqlConnectionStringBuilder
{
DataSource = serverName,
InitialCatalog = databaseName,
IntegratedSecurity = true
};
var providerString = sqlBuilder.ToString();
var entityBuilder = new EntityConnectionStringBuilder
{
Provider = providerName,
ProviderConnectionString = providerString,
Metadata = String.Format(metadataBase, Constants.ModelName)
};
var connStr = entityBuilder.ToString();
return connStr;
I'm new to Oracle, and I have installed Oracle Database 11g.
When I open some connection on Oracle SQL Developer, I get a dialog where I've to enter the username and the password as the following :
The problem is that I don't knwo what is the username and the password, in the installation I choosed orcl as the Username and orcl as the password but when I enter them I get the error message :
How can I solve this problem ?
I've another question : what is this page https://localhost:1158/em and why I get Page Web Inaccessible when I acces to it.
EDIT 1 :
This is the content of the listener.ora file :
# listener.ora Network Configuration File: C:\app\Aimad\product\11.2.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\Aimad\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:C:\app\Aimad\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
ADR_BASE_LISTENER = C:\app\Aimad
EDIT 2:
this is the output of the command tnsping xe :
The reason why you are getting the error is because you have not specified service name or SID as it doesn't know to which instance it should connect.
I suppose you are using one of the latest versions of SQL Developer available for download.
Right click connections and choose New Connection from context menu, you will get a window like one is pasted below, there you enter connection details and do not forget to enter either service name or SID.
Hope this helps.
Details:
username is scott
password is tiger
Server name - I gave prashanth-PC, which I found in tnsnames.ora - at this point I get
ORA-12154: TNS:could not resolve the connect identifer specified
When I connect using code, it is working. In code I will leave data source blank. But when I connect using the grid view tool. It is asking server name. I don't know which server name should I specify. For reference I have posted the contents of my "tnsnames.ora" file. Please check it. Am using Oracle 10g.
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = prashanth-PC)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
I'm assuming you're using the ".Net Framework Data provider for oracle" as your provider.
In this case the server name should contain the "alias" from your tnsnames.ora - in your case "XE".
The error you get may be caused because it can't find the tnsnames.ora file.
Make sure you set the "TNS_ADMIN" environment variabl to point to the path of the directory containing the tnsnames.ora file.
Server name expects the Oracle service name, not your machine host name. Try entering XE at the server name. If this fails:
Check if you have multiple tnsnames.ora file
If so, ensure all the tnsnames.ora files are in sync or find out which tnsnames.ora
is in use - This can be done by checking your path variable & finding out which path has the first mention of tnsnames.ora
Also ensure that the tns listener service is up & running from the Windows Services list
I faced this issue just now. What I was trying to do was to provide share to the TNS files folder, located under "Admin" folder of the oracle client installation location, with developer folks to ensure that the sanity of TNSentries on the server.
What I noticed was that when I applied the share over the "Admin" folder, the "(LocalHostName)\Authenticated Users" was removed from the security context of the "Admin" folder.
Once I added "Authenticated Users" back to the security context of the folder with default rights, the error was gone.
OS version: Win 2012 DC Edition
Oracle client Client: Oracle client 11.2.0