本文转自:http://www.connectionstrings.com/oracle/

    • Standard

      Data Source=MyOracleDB;Integrated Security=yes;

      This one works only with Oracle 8i release 3 or later

      Oracle
    • Specifying username and password

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

      This one works only with Oracle 8i release 3 or later

      Oracle
    • Omiting tnsnames.ora

      This is another type of Oracle connection string that doesn't rely on you to have a DSN for the connection. You create a connection string based on the format used in the tnsnames.ora file without the need to actually have one of these files on the client pc.

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

        Oracle
    •  
    • Omiting tnsnames.ora Alternative

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

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

        Oracle
    • Using Connection Pooling

      The connection pooling service will create a new pool if it can't find any existing pool that exactly match the new connections connection string properties. If there is a matching pool a connection will be recycled from that pool.

      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;

      The first connection opened creates the connection pool. The service initially creates the number of connections defined by the Min Pool Size parameter.

      The Incr Pool Size attribute defines the number of new connections to be created by the connection pooling service when more connections are needed.

      When a connection is closed, the connection pooling service determines whether the connection lifetime has exceeded the value of the Connection Lifetime attribute. If so, the connection is closed; otherwise, the connection goes back to the connection pool.

      The connection pooling service closes unused connections every 3 minutes. The Decr Pool Size attribute specifies the maximum number of connections that can be closed every 3 minutes.

      Oracle
    • Windows Authentication

      Data Source=myOracleDB;User Id=/;

        Oracle
    • Privileged Connection with SYSDBA privileges

      Data Source=myOracleDB;User Id=SYS;Password=SYS;DBA Privilege=SYSDBA;

        Oracle
    • Privileged Connection with SYSOPER privileges

      Data Source=myOracleDB;User Id=SYS;Password=SYS;DBA Privilege=SYSOPER;

        Oracle
    • Utilizing the Password Expiration functionality

      First open a connection with a connection string. When the connection is opened, an error is raised because the password have expired. Catch the error and execute the OpenWithNewPassword command supplying the new password.

      Data Source=myOracleDB;User Id=myUsername;Password=myPassword; 
      oConn.OpenWithNewPassword(sTheNewPassword);

        Oracle
    • Proxy Authentication

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

        Oracle

    ↯ Problems connecting?   Get answer in the Oracle Q & A forum →

  • dotConnect for Oracle

    • Standard

      User ID=myUsername;Password=myPassword;Host=ora;Pooling=true;Min Pool Size=0; Max Pool Size=100;Connection Lifetime=0;

        Oracle
  • Oracle Data Provider for .NET / ODP.NET

    • Using TNS

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

        Oracle
    • Using integrated security

      Data Source=TORCL;Integrated Security=SSPI;

        Oracle
    • Using ODP.NET without tnsnames.ora

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

      Article: "Oracle Data Provider for .NET" by Rama Mohan

      Oracle
    • 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/my.service.com;

      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

      Oracle
    • 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;

        Oracle
    • 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.

      Oracle
    • 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;

      The first connection opened creates the connection pool. The service initially creates the number of connections defined by the Min Pool Size parameter.

      The Incr Pool Size attribute defines the number of new connections to be created by the connection pooling service when more connections are needed.

      When a connection is closed, the connection pooling service determines whether the connection lifetime has exceeded the value of the Connection Lifetime attribute. If so, the connection is closed; otherwise, the connection goes back to the connection pool.

      The connection pooling service closes unused connections every 3 minutes. The Decr Pool Size attribute specifies the maximum number of connections that can be closed every 3 minutes.

      Oracle
    • 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;

      The Max Pool Size attribute sets the maximum number of connections for the connection pool. If a new connection is requested, but no connections are available and the limit for Max Pool Size has been reached the connection pooling service waits for the time defined by the Connection Timeout attribute. If the Connection Timeout time has been reached, and there are still no connections available in the pool, the connection pooling service raises an exception indicating that the request has timed-out.

      Oracle
    • Disable Pooling

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

        Oracle
    • 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.

      Oracle
    • 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.

      Oracle
    • 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).

      Oracle
  • Oracle in OraHome92

    • Standard

      Driver={Oracle in OraHome92};Dbq=myTNSServiceName;Uid=myUsername;Pwd=myPassword;

        Oracle
  • Oracle in XEClient

    • Standard

      Oracle XE (or "Oracle Database 10g Express Edition") is a simple version that's free to distribute.

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

        Oracle
  • Oracle in OraClient11g_home1

    • Standard

      Driver={Oracle in OraClient11g_home1};Dbq=myTNSServiceName;Uid=myUsername; Pwd=myPassword;

        Oracle
    • Server SID

      Driver={Oracle in OraClient11g_home1};Server=serverSID;Uid=myUsername; Pwd=myPassword;

        Oracle
    • Both Server and Dbq

      ODBC;Driver={Oracle in OraClient11g_home1};SERVER=[server SID];UID=[userid]; PWD=[password];DBQ=[server SID];

      Some feedback on using both Dbq and Server keywords to make this work.

      Oracle
  • Oracle Provider for OLE DB

    • Standard Security

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

        Oracle
    • Trusted Connection

      This one specifies OS authentication to be used when connecting to an Oracle database.

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

        Oracle
    • Oracle XE, VB6 ADO

      Provider=OraOLEDB.Oracle;dbq=localhost:1521/XE;Database=myDataBase; User Id=myUsername;Password=myPassword;

        Oracle
    • Oracle XE, C++ ADO

      Provider=OraOLEDB.Oracle;Data Source=localhost:1521/XE; Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

        Oracle
    • TNS-less connection string

      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
    • Controling rowset cache mechanism

      Specifies the type of caching used by the provider to store rowset data. OraOLEDB provides two caching mechanisms; File and Memory.

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

      Memory is the default value. All the rowset data is stored in-memory which provides better performance at the expense of higher memory utilization.

      File = All the rowset data is stored on disk. This caching mechanism limits the memory consumption at the expense of performance.

      Oracle
    • Controling the fetchsize

      This one specifies the number of rows the provider will fetch at a time (fetch array).

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

      The FetchSize value must be set appropriately depending on the data size and the response time of the network. If the value is set too high, this could result in more wait time during the execution of the query. If the value is set too low, this could result in many more round trips to the database. Valid values are 1 to 429,496,296. The default is 100.

      Oracle
    • Controling the chunksize

      This one specifies the size, in bytes, of the data in LONG and LONG RAW columns fetched and stored in the provider cache.

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

      Providing a high value for this attribute improves performance, but requires more memory to store the data in the rowset. Valid values are 1 to 65535. The default is 100.

      Oracle
    • Using with Microsofts OLE DB .NET Data Provider

      The Microsoft OLE DB .NET Data Provider can utilize OraOLEDB as the OLE DB Provider for accessing Oracle. However this must be enabled in the connection string.

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

      The OLEDB.NET connection string attribute must not be used in ADO applications.

      Oracle
    • Using OraOLEDB Custom Properties with Microsofts OLE DB .NET Data Provider

      The SPPrmsLOB and NDatatype properties can only be set as connection string attributes when OraOLEDB is used by OLE DB .NET Data Provider.

      Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername; Password=myPassword;OLEDB.NET=True;SPPrmsLOB=False;NDatatype=False; SPPrmsLOB=False;

      Using ADO, these properties would have been set as a property on the command. This is not possible if using the Microsofts OLE DB .NET Data Provider. So the properties are specified in the connection string instead.

      PLSQLRSet: If the stored procedure, provided by the consumer, returns a rowset, PLSQLRSet must be set to TRUE (enabled).

      NDatatype: This property allows the consumers to specify whether any of the parameters bound to the command are of Oracle's N datatypes (NCHAR, NVARCHAR or NCLOB). This information is required by OraOLEDB to detect and bind the parameters appropriately. This property should not be set for commands executing SELECT statements. However, this property must be set for all other SQLs such as INSERT, UPDATE, and DELETE.

      SPPrmsLOB: This property allows the consumer to specify whether one or more of the parameters bound to the stored procedures are of Oracle's LOB datatype (CLOB, BLOB, or NCLOB). OraOLEDB requires this property to be set to TRUE, in order to fetch the parameter list of the stored procedure prior to execution. The use of this property limits the processing overhead to stored procedures having one or more LOB datatype parameters.

      Oracle
    • Using distributed transactions

      This one specifies sessions to enlist in distributed transactions. This is the default behaviour.

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

      Valid values are 0 (disabled) and 1 (enabled).

      Oracle
  • Microsoft OLE DB Provider for Oracle

    • Standard security

      This connection string uses a provider from Microsoft.

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

        Oracle
    • Trusted connection

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

        Oracle
  • .NET Framework Data Provider for OLE DB

    • Use an OLE DB provider from .NET

      Provider=any oledb provider's name;OledbKey1=someValue;OledbKey2=someValue;

      See the respective OLEDB provider's connection strings options. The .net OleDbConnection will just pass on the connection string to the specified OLEDB provider. Read more here.

    • Use 'Oracle Provider for OLE DB' from .NET

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

      Note! The keyword "OLEDB.NET" must be set to "True" for the OraOLEDB.Oracle provider to function with the .NET Framework Data Provider for OLE DB.

      Oracle
  • Microsoft ODBC Driver for Oracle

    • Old version

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

        Oracle
  • Microsoft ODBC for Oracle

    • New version

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

        Oracle
    • Connect directly

      No TSN nor DSN required.

      Driver={Microsoft ODBC for Oracle}; Server=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=199.199.199.199)(PORT=1523))(CONNECT_DATA=(SID=dbName))); Uid=myUsername;Pwd=myPassword;

        Oracle
    • Without TSN.ora alternative

      Driver={Microsoft ODBC for Oracle}; CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=server)(PORT=7001))(CONNECT_DATA=(SERVICE_NAME=myDb))); Uid=myUsername;Pwd=myPassword;

        Oracle
  • .NET Framework Data Provider for ODBC

    • Use an ODBC driver from .NET

      Driver={any odbc driver's name};OdbcKey1=someValue;OdbcKey2=someValue;

      See the respective ODBC driver's connection strings options. The .net OdbcConnection will just pass on the connection string to the specified ODBC driver. Read more here.

  • MSDataShape

    • MSDataShape (Oracle)

      Provider=MSDataShape;Persist Security Info=False;Data Provider=MSDAORA; Data Source=orac;User Id=myUsername;Password=myPassword;

        Oracle

Articlesread all

[转]Oracle connection strings的更多相关文章

  1. Windows Phone本地数据库(SQLCE):9、Connection Strings(翻译) (转)

    这是“windows phone mango本地数据库(sqlce)”系列短片文章的第八篇. 为了让你开始在Windows Phone Mango中使用数据库,这一系列短片文章将覆盖所有你需要知道的知 ...

  2. [转】[tip] localhost vs. (local) in SQL Server connection strings

    主要区别在于连接协议不同,前者(localhost)使用TCP协议,后者("(local)")使用NamedPipe协议. Sample code with SQL Server ...

  3. How to: Secure Connection Strings When Using Data Source Controls

    https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-3.0/dx0f3cf2(v=vs.85) When wo ...

  4. SQLite connection strings

    Basic Data Source=c:\mydb.db;Version=3; Version 2 is not supported by this class library. SQLite In- ...

  5. Adaptive Server Enterprise ODBC driver connection strings

    Adaptive Server Enterprise 15.0 Driver={Adaptive Server Enterprise};app=myAppName;server=myServerAdd ...

  6. Web Api 2, Oracle and Entity Framework

    Web Api 2, Oracle and Entity Framework I spent about two days trying to figure out how to expose the ...

  7. Configuring and troubleshooting a Schema Provider

    原文:https://codesmith.atlassian.net/wiki/display/Generator/Configuring+and+troubleshooting+a+Schema+P ...

  8. Oracle中Error while performing database login with the XXXdriver; Listener refused the connection with the following error; ORA-12505,TNS:listener does not currently know of SID given inconnect descrip

    一次连接数据库怎么也连接不上,查了多方面资料,终于找到答案,总结 首先应该保证数据库的服务启动 在myeclipse的数据库视图中点 右键->new 弹出database driver的窗口,  ...

  9. ORACLE 导出(exp) & 导入(imp)

    导出(exp) & 导入(imp)     利用Export可将数据从数据库中提取出来,就是将select的结果存到一个FS二进制文件上    利用Import则可将提取出来的数据送回到Ora ...

随机推荐

  1. Android Studio代码字体模糊解决方法

    问题描述: 我的电脑分辨率是(1920*1080),然而安装了Android Studio后代码的一些部分区域出现模糊的现象,应该是软件默认设置与高分屏有冲突. 如下图所示. 解决方法: 打开设置对话 ...

  2. Python Flask装饰器登录验证

    from flask import Flask,render_template,redirect,request,session app = Flask(__name__) app.secret_ke ...

  3. react初体验

    function Guest() { return ( <h1>pls login in</h1> ); } function User() { return ( <h1 ...

  4. AC日记——「HNOI2017」单旋 LiBreOJ 2018

    #2018. 「HNOI2017」单旋 思路: set+线段树: 代码: #include <bits/stdc++.h> using namespace std; #define max ...

  5. 阿里云Maven仓库配置,Maven镜像配置

    Jenkins通过maven对java代码打包编译时,速度太慢,所以修改为阿里的Maven仓库 修改如下: [root@7mini-node2 conf]# vim /software/apache- ...

  6. 简单邮件传输协议SMTP

    1.SMTP是由源地址到目的地址传送邮件的一组规则,用来控制信件的中转方式. 2.SMTP服务器是遵循SMTP协议的发送邮件服务器,用来发送或者中转发出的邮件,客户端通过SMTP命令与SMTP服务器进 ...

  7. HDU 6463.超级无敌简单题-卡边界的暴力 (“字节跳动-文远知行杯”广东工业大学第十四届程序设计竞赛)

    超级无敌简单题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

  8. JavaScript的基础学习(一)

    一.JavaScript概述 JavaScript的历史 1992年Nombas开发出C-minus-minus(C--)的嵌入式脚本语言(最初绑定在CEnvi软件中).后将其改名ScriptEase ...

  9. TensorFlow-GPU安装配置(win10+tensorflow1.6+CUDA9.0+cudnn7.0+python3.6+Visual Studio2013)

    安装步骤: TensorFlow官网 tensorflow一般只能装在python3上,CUDA9.0搭配cudnn7.0,CUDA8.0搭配cudnn6.0 查看对应要安装的环境版本(因为会不断更新 ...

  10. linux——(2)文件权限与目录配置

    概念一:用户与用户组 对linux下的每一个文件或者目录来说,访问者都有三种身份:所有者,用户组,其他人.这三种人对于同一个文件的权限是可以分开设定的. 概念二:linux文件权限 文件和目录都有3种 ...