I am trying to connect to the Vendor's database through the Wallet. For that, the vendor has provided a wallet zip files which contains two files (one .ora file and one .sso file) . The zip file contains tnsnames.ora and cwallet.sso
First, I installed the Oracle client version 19.0 Home1 which has created a file called sqlnet.ora automatically. I copied the file tnsnames.ora to the same folder where sqlnet.ora created, and tried different wasys to connect the database, but every attempt failed. I tried to implement in similar way which is explained in this link, but getting errors that "TNS:Lost contact", "TNS:Could not resolved the connect identifier specified".
I tried the solution which specified here, but ended up in error. Finally, the error now is "Connection failed because target host or object does not exist". The connection details are specified in tnsnames. ora that contains the service name and host name. I have added the Wallet location in sqlnet.ora file and also the following code:
SSL_CLIENT_AUTHENTICATION = FALSE
SSL_VERSION = 1.2
SSL_CIPHER_SUITES = (SSL_RSA_WITH_AES_256_CBC_SHA)
SSL_SERVER_DN_MATCH = ON
The connection code in C# is below:
//string strCon = "User Id =XXXX;Password=XXXXXXX;Data Source=(DESCRIPTION =(ADDRESS=(PROTOCOL=TCP)(HOST=XXXXXXXX)(PORT=2460))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XXXX))" +
// "(SECURITY=(SSL_SERVER_CERT_DN='C=US,ST=Washington,L=Seattle,O=Amazon.com,OU=RDS,CN=mcsldb01.ckc6ued9hacf.ap-south1.rds.amazonaws.com')));";
using (OracleConnection con = new OracleConnection(strCon))
//using (OracleConnection con = new OracleConnection(#"Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=XXXXXXXX)(PORT=2460)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XXXX)));User Id=XXXX;Password=XXXXXXXX;"))
//using (OracleConnection con = new OracleConnection(cntn))
{
using (OracleCommand cmd = con.CreateCommand())
{
try
{
//TNS_ADMIN and wallet directory entries can be entered in the app.config file.
con.Open();
Console.WriteLine("Successfully connected to Oracle Autonomous Database");
//Retrieve database version info
cmd.CommandText = "SELECT BANNER FROM V$VERSION";
OracleDataReader reader = cmd.ExecuteReader();
reader.Read();
Console.WriteLine("Connected to " + reader.GetString(0));
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadLine();
}
}
}
Please suggest any solution. Where I am going wrong? Not able to proceed further.
At a guess, it might have been a connection wallet not an SSL wallet that has been provided, ie, just a mechanism of hiding the username and password. If that is the case, the connection would look something like:
new OracleConnection(#"Data Source=NAME_IN_TNSNAMES;User Id=/"))
where NAME_IN_TNSNAMES maps to the entry in the tnsnames.ora file.
Examples of that (from a SQL Plus perspective) here
https://connor-mcdonald.com/2015/09/21/connection-shortcuts-with-a-wallet/
Related
I'm trying to write a method for checking SQLite file existence. I downloaded a Nuget package for SQLite functionalities named System.Data.SQLite.Core.
I wrote this code for the method:
string path = "ReportData.db";
private void Create_db()
{
if (!System.IO.File.Exists(path))
{
SQLiteConnection.CreateFile(path);
using (var sqlite = new SQLiteConnection(#"Data Source=" + path))
{
sqlite.Open();
string sql = "create table temp(date varchar(20),activity varchar(1000))";
SQLiteCommand command = new SQLiteCommand(sql, sqlite);
command.ExecuteNonQuery();
sqlite.Close();
}
}
}
I don't know where to create my SQLite database file. When I use this method in a button, the application goes into break mode and says:
System.UnauthorizedAccessException: 'Access to the path
"/ReportData.db" is denied.'
Please help me.
I'm quite new to Oracle and never used that before, now, I'm trying to query an Oracle database from a .Net Core Web Application having nuget package oracle.manageddataaccess.core installed and using an alias as the Data Source but I'm receiving the following error:
If I use the full connection string the query will work correctly
ORA-12154: TNS:could not resolve the connect identifier specified
at OracleInternal.Network.AddressResolution..ctor(String TNSAlias, SqlNetOraConfig SNOConfig, Hashtable ObTnsHT, String instanceName, ConnectionOption CO)
at OracleInternal.Network.OracleCommunication.Resolve(String tnsAlias, ConnectionOption& CO)
at OracleInternal.ConnectionPool.PoolManager`3.ResolveTnsAlias(ConnectionString cs, Object OC)
at OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession, OracleConnection connRefForCriteria, String instanceName)
So, from a few links I could understand that there is a tsnnames.ora file which must contain the map between connect identifiers and connect descriptors. And that this file can be found at the machine on which the Oracle has been installed with the path ORACLE_HOME\network\admin.
Question is:
Does the alias name that I'm using in my connection string which reads as Data Source: <alias_name>; User ID=<user>; Password=<password> need to be specified in the tsnnames.ora file? I don't have access to the machine where the Oracle database resides on otherwise I would have checked it earlier.
Here's the code snippet for more info: connection string and query values are mocked out
public static string Read()
{
const string connectionString = "Data Source=TestData;User ID=User1;Password=Pass1";
const string query = "select xyz from myTable";
string result;
using (var connection = new OracleConnection(connectionString))
{
try
{
connection.Open();
var command = new OracleCommand(query) { Connection = connection, CommandType = CommandType.Text };
OracleDataReader reader = command.ExecuteReader();
reader.Read();
result = reader.GetString(0);
}
catch (Exception exception)
{
Console.WriteLine(exception);
throw;
}
}
return result;
}
Is this enough or something else needs to be added/changed in here? Or probably the issue is with the tsnNames.ora file which might not contain the alias name here?
Thanks in advance
For the Data source
Data Source=TestData;User Id=myUsername;Password=myPassword;
Your tnsnames.ora probably should have the below entry
TestData=(DESCRIPTION=
(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost) (PORT=MyPort)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)))
Since
Data Source=TestData;User Id=myUsername;Password=myPassword;
is same as
Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost) (PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;
I am trying to connect to a MySQL server using Jdbc for Google Apps and getting an error as follows:
Failed to establish a database connection. Check connection string,
username and password. (line 10, file "dbadmin")
The following is a snipet of the code I am using:
var address = 'w.x.y.z';
var user = 'user';
var userPwd = 'password';
var db = 'dbname';
var dbUrl = 'jdbc:mysql://' + address + '/' + db;
var conn = Jdbc.getConnection(dbUrl, user, userPwd);
I have successfully connected to the Database from my own computer using both the IP and Hostname. I have confirmed the server should be accepted connections from ALL IPs for that account, and confirmed the ruleset is working by removing the whitelisting and adding it back again.
I am basically out of troubleshooting ideas of what is going on. What am I doing wrong, or what is wrong with Google?
A typical way to establish JDBC connection is as follows:
String url = "jdbc:mysql://hostname:3306/mydb";
String username = "username";
String password = "password"
Connection conn = DriverManager.getConnection(url, username, password);
You can refer to this for more detailed information.
My connection is failing with the following message: "The procedure entry point ons_subscriber_cancelcallback could not be located in the dynamic link library oraons.dll".
Can anyone please help ?
The code is pretty straight forward:
string oradb = "";
oradb = "Data Source=MYORADB;Password=MYPASS123;User ID=MYUSERID;";
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
I have already connected TOAD with these credentials.
For me, the solution was to go to the Oracle website where I downloaded and installed the latest version of the Oracle Data Access Components (ODAC).
You'll want to be careful to install the correct version for your programming environment. In my case, it was version 12c (64-bit).
From there, I redirected the Oracle.DataAccess.dll reference to the version that I'd just installed.
You don't seem to have a database IP or port number there. Once you have those available, try using the Oracle EZCONNECT format:
//Check that MYORADB is your actual SID number
string oradb = getConnectionString("10.1.2.3", 1521, "MYORADB", "MYUSERID", "MYPASS123");
OracleConnection conn = new OracleConnection(oradb);
conn.Open();
private static string getConnectionString(string databaseIP, int databasePort, string databaseSID, string databaseUN, string databasePW)
{
return string.Format(
"Data Source=(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = {0})(PORT = {1}))(CONNECT_DATA =(SID = {2})));" +
"Persist Security Info=True;User ID={3};Password={4}",
databaseIP, databasePort, databaseSID, databaseUN, databasePW
);
}
I'm complete newbie to Oracle DB trying to enable DB change notifications.
private void RegisterNotification()
{
const string connstring = "Data Source=ORA_DB;User Id=USER;Password=pass;";
try
{
var connObj = new OracleConnection(connstring);
connObj.Open();
var cmdObj = connObj.CreateCommand();
cmdObj.CommandText = "SELECT * FROM MYTABLE";
var dep = new OracleDependency(cmdObj);
dep.QueryBasedNotification = false;
dep.OnChange += new OnChangeEventHandler(OnNotificationReceived);
cmdObj.ExecuteNonQuery();
connObj.Close();
connObj.Dispose();
connObj = null;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
public static void OnNotificationReceived(object src, OracleNotificationEventArgs arg)
{
MessageBox.Show("Table has changed!");
}
I've executed "GRANT CHANGE NOTIFICATION TO USER;" but nothing happens when I change the table data neither manually nor programmatically. Query-based notifications also don't work. I suppose I miss something in Oracle configuration.
I have Oracle 11.2 standard edition.
The CHANGE NOTIFICATION permission is not on the features of the Standard Edition for latest versions :
Licensing information
Oracle TimesTen Application-Tier Database Cache :
Data access using PL/SQL, JDBC, ODBC, ttClasses, OCI, and Pro*C/C++
interfaces Transaction Log API (XLA) for change notification
Multi-node Cache Grid
...
SE2 : N
EE : Y (extra-cost option)
Try to execute your soft under admin permission and as console application. when we used to deal with it we faced with the same stuff. we hadn't managed to use it in webservices.