Oracle connection strings - different types


What are all the different types of connection strings used to connect oracle database from .net application?

edit | flag
William Patrick
Asked on: Oct 12, 2011 at 12:01AM

1 Answers


Using TNS

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

Using integrated security

Data Source=TORCL;Integrated Security=SSPI;

Using ODP.NET without tnsnames.ora


Using the Easy Connect Naming Method (aka EZ Connect)

The easy connect naming method enables clients to connect to a database without any configuration.

Data Source=username/password@//myserver:1521/;

Port 1521 is used if no port number is specified in the connection string.

Make sure that EZCONNECT is enabled in the sqlnet.ora file. NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

'//' in data source is optional and is there to enable URL style hostname values

Easy Connect Naming Method to connect to an Instance

This one does not specify a service or a port.

Data Source=username/password@myserver//instancename;

Easy Connect Naming Method to connect to a dedicated server instance

This one does not specify a service or a port.

Data Source=username/password@myserver/myservice:dedicated/instancename;

Other server options: SHARED, POOLED (to use instead of DEDICATED). Dedicated is the default.

Specifying Pooling parameters

By default, connection pooling is enabled. This one controls the pooling mechanisms. The connection pooling service creates connection pools by using the ConnectionString property to uniquely identify a pool.

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

Restricting Pool size

Use this one if you want to restrict the size of the pool.
Data Source=myOracle;User Id=myUsername;Password=myPassword;Max Pool Size=40;Connection Timeout=60;

Disable Pooling

Data Source=myOracle;User Id=myUsername;Password=myPassword;Pooling=False;

Using Windows user authentication

Oracle can open a connection using Windows user login credentials to authenticate database users.
Data Source=myOracle;User Id=/;

If the Password attribute is provided, it is ignored.

Operating System Authentication is not supported in a .NET stored procedure.

Privileged Connections

Oracle allows database administrators to connect to Oracle Database with either SYSDBA or SYSOPER privileges.

Data Source=myOracle;User Id=myUsername;Password=myPassword;DBA Privilege=SYSDBA;

SYSOPER is also valid for the DBA Privilege attribute.

Runtime Connection Load Balancing

Optimizes connection pooling for RAC database by balancing work requests across RAC instances.

Data Source=myOracle;User Id=myUsername;Password=myPassword;Load Balancing=True;

This feature can only be used against a RAC database and only if pooling is enabled (default).

edit | flag
Gokul A
Answered on: Oct 12, 2011 at 12:08AM

Post your Answer


Welcome to Ask Amoeba!
This is 100% free and interactive site for sharing professional Questions and Answers, Opensource projects, Interview questions.
Learners, beginners, Experts stop and share your knowledge and ideas!

Browse Categories

Browse Tags