c#,oracle的連接字串,sys使用者的解決辦法。

來源:互聯網
上載者:User
oracle|解決|字串 System.Data.OracleClientOracleConnection.ConnectionString 屬性下表為 ConnectionString 內的值列出了有效名稱。

名稱 預設值 說明
資料來源或伺服器   要串連的oracle執行個體的名稱或網路地址
整合式安全性 'false' 該串連是否為安全的串連。 可識別的值為 true(極力建議使用)、falseyesno
密碼   Oracle 帳戶的登入密碼(建議不要使用。為了保持較高的安全層級,極力建議您改用整合式安全性關鍵字。)
持續安全資訊 'false' 當設定為 falseno(強烈建議)時,如果串連是開啟的或者一直處於開啟狀態的 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
 


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.