Using Statements with the JDBC Driver

The Microsoft SQL Server JDBC Driver can be used to work with data in a SQL Server database in a variety of ways. The JDBC driver can be used to run SQL statements against the database, or it can be used to call stored procedures in the database, using both input and output parameters. The JDBC driver also supports using SQL escape sequences, update counts, automatically generated keys, and performing updates within a batch operation.

The JDBC driver provides three classes for retrieving data from a SQL Server database:

  1. SQLServerStatement - used for running SQL statements without parameters.

  2. SQLServerPreparedStatement - (inherited from SQLServerStatement), used for running compiled SQL statements that might contain IN parameters.

  3. SQLServerCallableStatement - (inherited from SQLServerPreparedStatement), used for running stored procedures that might contain IN parameters, OUT parameters, or both.

The topics in this section discuss how you can use each of the three statement classes to work with data in a SQL Server database.

In This Section

Topic Description

Using Statements with SQL

Describes how to use SQL statements with the JDBC driver to work with data in a SQL Server database.

Using Statements with Stored Procedures

Describes how to use stored procedures with the JDBC driver to work with data in a SQL Server database.

Using Multiple Result Sets

Describes how to use the JDBC driver to retrieve data from multiple result sets.

Using SQL Escape Sequences

Describes how to use SQL escape sequences, such as date and time literals and functions.

Using Auto Generated Keys

Describes how to use automatically generated keys.

Performing Batch Operations

Describes how to use the JDBC driver to perform batch operations.

Handling Complex Statements

Describes how to use the JDBC driver to run complex statements that perform a variety of tasks and might return different types of data.

See Also

Other Resources

Overview of the JDBC Driver