| title | Connecting and retrieving data |
|---|---|
| description | Learn how to connect to a SQL database and retrieve data using the Microsoft JDBC Driver for SQL Server and these code samples. |
| author | David-Engel |
| ms.author | davidengel |
| ms.date | 08/12/2019 |
| ms.service | sql |
| ms.subservice | connectivity |
| ms.topic | integration |
[!INCLUDEDriver_JDBC_Download]
When you are working with the [!INCLUDEjdbcNoVersion], there are two primary methods for establishing a connection to a [!INCLUDEssNoVersion] database. One is to set connection properties in the connection URL, and then call the getConnection method of the DriverManager class to return a SQLServerConnection object.
Note
For a list of the connection properties supported by the JDBC driver, see Setting the connection properties.
The second method involves setting the connection properties by using setter methods of the SQLServerDataSource class, and then calling the getConnection method to return a SQLServerConnection object.
The topics in this section describe the different ways in which you can connect to a [!INCLUDEssNoVersion] database, and they also demonstrate different techniques for retrieving data.
| Topic | Description |
|---|---|
| Connection URL Sample | Describes how to use a connection URL to connect to [!INCLUDEssNoVersion] and then use a SQL statement to retrieve data. |
| Data Source Sample | Describes how to use a data source to connect to SQL Server and then use a stored procedure to retrieve data. |