Oracle 连接串方式

1.Connecting via TNS

"Data Source=NEWDB;User ID=SYSTEM;Password=admin";

2.Connecting Without TNSNames.ora

"Data Source = " +
      "(DESCRIPTION = " + 
    "  (ADDRESS_LIST = " + 
        "    (ADDRESS = (PROTOCOL = TCP)" + 
    "    (HOST = 127.0.0.1) " +
    "    (PORT = 1521) " +
    "   )" + 
    "  )" + 
    "  (CONNECT_DATA = " + 
    "   (SERVICE_NAME = NEWDB)" +
    "  )" + 
    ");" + 
    "User Id=SYSTEM;" + 
    "password=admin;"

3. Connecting via EZConnect

"Data Source=EDZEHOO-PC:1521/NEWDB;
    User ID=SYSTEM;Password=admin";

4. Connecting with Connection Pooling Activated

OracleConnection conn = new OracleConnection();
conn.ConnectionString = "Data Source=NEWDB;
   User ID=SYSTEM;
Password=admin;
   Min Pool Size=10;
   Max Pool Size=100;
   Connection Lifetime=120;
   Connection Timeout=60;
   Incr Pool Size=3;
   Decr Pool Size=1;"

5. Dynamically Building an ODP.NET Connection String

 

private string BuildConnectionString(string TNSName, string UserID, string
Password)
{
    OracleConnectionStringBuilder _conn = new OracleConnectionStringBuilder();
    {
        _conn.DataSource = TNSName;
        _conn.DecrPoolSize = 5;
        _conn.IncrPoolSize = 10;
        _conn.Pooling = true;
        _conn.MaxPoolSize = 100;
        _conn.MinPoolSize = 5;
  _conn.ConnectionLifeTime = 120
        _conn.ConnectionTimeout = 60
        _conn.UserID = UserID;
        _conn.Password = Password; 
    }
    return _conn.ConnectionString;
}

 

你可能感兴趣的:(oracle)