简体   繁体   中英

Oracle ODP.NET connection string: what goes in Data Source?

This is the ConnectionStrings.com string of ODP.NET, great, but what is Data Source?

Data Source=TORCL;User Id=someUser;Password=son28dnn;

Is it a DSN in Control Panel?

A server name?

A TNS names service name?

Thanks

Luke

If you are using ODP.NET with TNS which is nothing but one of the adapter for connecting to the oracle database.The file for maintaining the TNS Entries is Tnsnames.Ora

A Sample entry in tnsnames.ora(path for the file is normally ORACLE_HOME\\NETWORK\\ADMIN)sample entry looks like the below

TORCL=(DESCRIPTION=
(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)   (PORT=MyPort)))    
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=MyOracleSID)))

Here TORCL is an alias for the Data source ,MyHost is your Database server name or Ip Address,Port is the database listener port and MyOracleSID is your Oracle Service

Hence

Data Source=TORCL;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; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM