getconnection java_getConnection 方法 (java.lang.String, java.lang.String)

getConnection 方法 (java.lang.String, java.lang.String)getConnection Method (java.lang.String, java.lang.String)

01/19/2017

在此文章

嘗試與這個 SQLServerDataSource 物件所代表的資料來源建立連接,其方式是使用指定的使用者名稱和密碼。Tries to establish a connection with the data source that this SQLServerDataSource object represents by using the given user name and password.

語法Syntax

public java.sql.Connection getConnection(java.lang.String username,

java.lang.String password)

參數Parameters

usernameusername

包含使用者名稱的 字串。A String that contains the user name.

passwordpassword

包含密碼的 字串。A String that contains the password.

傳回值Return Value

例外狀況Exceptions

java.sql.SQLExceptionjava.sql.SQLException

備註Remarks

這個 getConnection 方法是由 javax.sql.DataSource 介面中的 getConnection 方法所指定。This getConnection method is specified by the getConnection method in the javax.sql.DataSource interface.

使用非 Null 使用者名稱或密碼呼叫 getConnection 方法時,將會取代初始化 SQLServerConnection 物件時,在 SQLServerDataSource 類別上所設定的使用者名稱與密碼屬性。Calling the getConnection method with a non-null user name or password will replace the user name and password properties that are set on the SQLServerDataSource class when initializing the SQLServerConnection object. 例如,如果呼叫者已經在資料來源上呼叫 setUser 和 setPassword,然後呼叫 getConnection 並提供非 Null 使用者名稱或非 Null 密碼,則 setUser 和 setPassword 所設定之使用者名稱和密碼將會由傳遞給 getConnection 的使用者名稱和密碼取代。For example, if the caller has called setUser and setPassword on the data source, and then calls getConnection and supplies a non-null user name or a non-null password, the user name and password set by setUser and setPassword will be replaced by the user name and password passed into getConnection.

注意

在此情況下,使用 setURL 方法的呼叫在 URL 內設定的使用者名稱和密碼將不會變更。The user name and password that are set inside the URL by using a call to the setURL method will not be changed in this case.

另請參閱See Also

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值