Επεξεργασία

Κοινή χρήση μέσω


Connecting and retrieving data

Download JDBC driver

When you are working with the Microsoft JDBC Driver for SQL Server, there are two primary methods for establishing a connection to a SQL Server 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 SQL Server database, and they also demonstrate different techniques for retrieving data.

In this section

Topic Description
Connection URL Sample Describes how to use a connection URL to connect to SQL Server 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.

See also

Sample JDBC driver applications