Skip to content

Latest commit

 

History

History
55 lines (39 loc) · 2.54 KB

getconnection-method-java-lang-string-java-lang-string.md

File metadata and controls

55 lines (39 loc) · 2.54 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic apilocation apiname apitype
getConnection Method (java.lang.String, java.lang.String)
getConnection Method (java.lang.String, java.lang.String)
David-Engel
davidengel
01/19/2017
sql
connectivity
reference
sqljdbc.jar
SQLServerDataSource.getConnection (java.lang.String, java.lang.String)
Assembly

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

[!INCLUDEDriver_JDBC_Download]

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

username

A String that contains the user name.

password

A String that contains the password.

Return Value

A SQLServerConnection object.

Exceptions

java.sql.SQLException

Remarks

This getConnection method is specified by the getConnection method in the javax.sql.DataSource interface.

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

Note

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

getConnection Method (SQLServerDataSource)
SQLServerDataSource Members
SQLServerDataSource Class