oracle|解決|字串 System.Data.OracleClientOracleConnection.ConnectionString 屬性下表為
ConnectionString 內的值列出了有效名稱。
| 名稱 |
預設值 |
說明 |
| 資料來源或伺服器 |
|
要串連的oracle執行個體的名稱或網路地址 |
| 整合式安全性 |
'false' |
該串連是否為安全的串連。 可識別的值為 true(極力建議使用)、false、yes 和 no。 |
| 密碼 |
|
Oracle 帳戶的登入密碼(建議不要使用。為了保持較高的安全層級,極力建議您改用整合式安全性關鍵字。) |
| 持續安全資訊 |
'false' |
當設定為 false 或 no(強烈建議)時,如果串連是開啟的或者一直處於開啟狀態的 State,那麼安全敏感的資訊(如密碼)就不會作為串連的一部分返回。重設連接字串將重設包括密碼在內的所有連接字串值。 |
| Unicode |
|
指定用於 Oracle 的.NET Framework 資料提供者是否使用 UTF16 模式 API 呼叫。除了未在 Oracle 9i 用戶端軟體中使用分散式交易的情況以外,該關鍵字在其他情況下都會被忽略。當不使用 Oracle 9i 用戶端軟體與 Oracle 9i 伺服器通訊時,如果 Unicode 設定為 true,可能發生不可預知的結果。 |
| 使用者識別碼 |
|
Oracle 登入帳戶(建議不要使用。為了保持較高的安全層級,極力建議您改用整合式安全性關鍵字。) |
當設定需要布爾值的關鍵字或串連池值時,您可以使用 'yes' 代替 'true','no' 代替 'false'。整數值表示為字串。
樣本
[Visual Basic, C#, C++] 下面的樣本建立一個 OracleConnection,並在連接字串中設定它的一些屬性。[Visual Basic] Public Sub CreateOracleConnection() Dim myConnString As String = _ "Data Source=Oracle8i;Integrated Security=yes" Dim myConnection As New OracleConnection(myConnString) myConnection.Open() MessageBox.Show("ServerVersion: " + myConnection.ServerVersion _ + ControlChars.NewLine + "DataSource: " + myConnection.DataSource) myConnection.Close()End Sub[C#] public void CreateOracleConnection() { string myConnString = "Data Source=Oracle8i;Integrated Security=yes"; OracleConnection myConnection = new OracleConnection(myConnString); myConnection.Open(); MessageBox.Show("ServerVersion: " + myConnection.ServerVersion + "\nDataSource: " + myConnection.DataSource); myConnection.Close();}[C++] public: void CreateOracleConnection() { String* myConnString = S"Data Source=Oracle8i;Integrated Security=yes"; OracleConnection* myConnection = new OracleConnection(myConnString); myConnection->Open(); MessageBox::Show(String::Format( S"ServerVersion: {0}\nDataSource: {1}", myConnection->ServerVersion, myConnection->DataSource )); myConnection->Close();
}
所以說,用.NET新提供的managed provider來訪問Oracle資料(System.Data.OracleClient),
是無法以sys使用者登入的。
這隻有使用Oracle ODP.NET(可以去oracle官方網站下載)
Oracle ODP.NET資料庫訪問連接字串
Connection String Attribute |
預設值 |
描述 |
| Connection Lifetime |
0 |
Maximum life time (in seconds) of the connection 當資料庫連接被返回到串連池中時,它的建立時間將與目前時間比較,如果超過了 Connection Lifetime 規定的時間,它將被釋放掉。 為 0 時將被視為最大連線時間。 |
| Connection Timeout |
15 |
Maximum time (in seconds) to wait for a free connection from the pool |
| Data Source |
empty string |
Oracle Net Service Name that identifies the database to connect to |
| DBA Privilege |
empty string |
Administrative privileges: SYSDBA or SYSOPER |
| Decr Pool Size |
1 |
Controls the number of connections that are closed when an excessive amount of established connections are unused |
| Enlist |
true |
Enables or disables serviced components to automatically enlist in distributed transactions 當此值為 true 時,池中現存的所有資料庫連接將被加入到它的建立線程的 Transaction Context 中。如果不存在這個 Transaction Context 則無任何變化。 |
| Incr Pool Size |
5 |
Controls the number of connections that are established when all the connections in the pool are used |
| Max Pool Size |
100 |
Maximum number of connections in a pool |
| Min Pool Size |
1 |
Minimum number of connections in a pool |
| Password |
empty string |
Password for the user specified by User Id |
| Persist Security Info |
false |
Enables or disables the retrieval of password in the connection string |
| Pooling |
true |
Enables or disables connection pooling |
| Proxy User Id |
empty string |
User name of the proxy user |
| Proxy Password |
empty string |
Password of the proxy user |
| User Id |
empty string |
Oracle user name |
// C# ... OracleConnection con = new OracleConnection(); con.ConnectionString = "User Id=
scott;Password=tiger;Data Source=
oracle;Pooling=true;Enlist=true;Min Pool Size=10;Connection Lifetime=120;Connection Timeout=60;Incr Pool Size=5; Decr Pool Size=2"; con.Open(); ...
以下網站提供連接字串大全:
www.ConnectionStrings.com