In depth analysis of C connection Oracle database connection string details

  • 2020-05-10 18:46:26
  • OfStack

Two ways: 1.IP+SID 2. Configure link mode
1.. IP + SID way

DbHelperOracle.connectionString = string.Format(@"Data Source=(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = {0})(PORT = 1521))
)
(CONNECT_DATA =
(SID = {1})
(SERVER = DEDICATED)
)
);User Id={2};Password={3};",
txtDBServerIP.Text.Trim(), txtOracleSID.Text.Trim(), txtDBUserName.Text.Trim(), txtDBPassword.Text.Trim());

This approach does not require the addition of link configuration information in the Oracle Net Manager administration.
2. 2. Configure the link mode,
Add link configuration information in Oracle Net Manager management, and then write the link string as follows:

Data Source=TORCL;User Id=myUsername;Password=myPassword;

Other ways of connection, please refer to the following, transferred from other websites:
Oracle connection string summary
Oracle XE
Standard connection
Oracle XE(or "Oracle Database 10g Express Edition") is a simple free release.
Here is the syntax:

Driver=(Oracle in XEClient);dbq=111.21.31.99:1521/XE;Uid=myUsername;Pwd=myPassword; 

ODBC
New version connection mode
Here is the syntax:

Driver={Microsoft ODBC for Oracle};Server=myServerAddress;Uid=myUsername;Pwd=myPassword; 

Old version connection mode
Here is the syntax:

Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword

OLE DB, OleDbConnection (.NET)
Standard safety connection
This connection USES Provider from Microsoft.
Here is the syntax:

Provider=msdaora;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword; 

Trusted connection
Here is the syntax:

Provider=msdaora;Data Source=MyOracleDB;Persist Security Info=False;Integrated Security=Yes; 

Standard safety connection
This connection USES Provider from Oracle.
Here is the syntax:

Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword; 

Trusted connection
Here is the syntax:

Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1; 

Here is the syntax:

Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=myHost)(PORT=myPort)))(CONNECT_DATA=(SID=MyOracleSID)(SERVER=DEDICATED)));User Id=myUsername;Password=myPassword; 

Oracle.DataAccess.Client.OracleConnection
Standard connection
Here is the syntax:

Data Source=TORCL;User Id=myUsername;Password=myPassword; 

Connection with integrated security
Here is the syntax:

Data Source=TORCL;Integrated Security=SSPI; 

Connection with ODP.NET without tnsnames.ora
Here is the syntax:

Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword;

OracleConnection, Oracle Data Provider, ODP.NET, System.Data.OracleClient.OracleConnection
Standard connection  
Here is the syntax:

Data Source=MyOracleDB;Integrated Security=yes 

Oracle8i release 3 or later   only
Specify the user secret and password connection  
Here is the syntax:

Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;Integrated Security=no; 

This is another way of connecting that doesn't depend on your DNS.You create a connection the format used the need to have one of these files on the client pc.  
Here is the syntax:

SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword; 

Some reported problems with the one above and Visual Studio. Use the next one if you've encountered problems.  
Here is the syntax:

Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));User Id=myUsername;Password=myPassword; 

Use connection pooling  
If the connection pool service cannot find a connection that matches the connection string exactly, it will create one. If the connection can be found, it will be reused.  
Here is the syntax:

Data Source=myOracleDB;User Id=myUsername;Password=myPassword;Min Pool Size=10;Connection Lifetime=120;Connection Timeout=60;Incr Pool Size=5;Decr Pool Size=2; 

Windows validation  
Here is the syntax:

Data Source=TORCL;User Id=myUsername;Password=myPassword;
8
Privileged connection
Use SYSOPER's privilege  
Here is the syntax:

Data Source=TORCL;User Id=myUsername;Password=myPassword;
9
Use the password termination function
When the connection is opened the first time, a password expiration error is thrown when the link is opened. This error is caught and the OpenWithNewPassword command line is executed to set the new password.  
Here is the syntax:

Driver=(Oracle in XEClient);dbq=111.21.31.99:1521/XE;Uid=myUsername;Pwd=myPassword; 
0
The agent validates  
Here is the syntax:

Data Source=myOracleDB;User Id=myUsername;Password=myPassword;Proxy User Id=pUserId;Proxy Password=pPassword 

Core Labs OraDirect (.NET)  
Standard connection

 Here is the syntax: 
User ID=myUsername;Password=myPassword;Host=ora;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;

Data Shape  
MS Data Shape  

 Here is the syntax: 
Provider=MSDataShape.1;Persist Security Info=False;Data Provider=MSDAORA;Data Source=orac;User Id=myUsername;Password=myPassword;


Related articles: