What's New in the JDBC Driver

The following sections discuss new features in the Microsoft SQL Server JDBC Driver.

What's New in the JDBC Driver Version 3.0

Microsoft SQL Server JDBC Driver 3.0 includes several new features and enhancements.

Driver Name

The new version of the JDBC driver is Microsoft SQL Server JDBC Driver 3.0.

Support for SQL Server 2008 Time and Date Data Types Introduced in SQL Server 2008

The Microsoft SQL Server JDBC Driver 3.0 now supports the following SQL Server data types:

  • time

  • date

  • datetime2

  • datetimeoffset

For more information about these SQL Server types, see Date and Time Data Types and Functions (Transact-SQL).

The DateTimeOffset Class type is added, as well as functions that allow you to access values in a datetimeoffset column:

Configuring How java.sql.Time Values are Sent to the Server

The sendTimeAsDatetime connection property is added. sendTimeAsDatetime determines how a java.sql.Time value will be sent to the server, as a SQL Server time or datetime value.

For information on using the sendTimeAsDatetime connection property, see Setting the Connection Properties.

For more information about sending java.sql.Time types to the server, see Configuring How java.sql.Time Values are Sent to the Server.

You can programmatically modify the value of the sendTimeAsDatetime connection property with SQLServerDataSource.setSendTimeAsDatetime.

Full Support for MERGE Operations

The following methods now return the correct number of rows updated for a MERGE operation:

getBytes, setBytes, and updateBytes not Supported with Date and Time Types

In the Microsoft SQL Server JDBC Driver 2.0, you could use SQLServerCallableStatement.getBytes, SQLServerCallableStatement.setBytes, SQLServerResultSet.getBytes, or SQLServerResultSet.updateBytes to convert values between byte arrays and SQL Server data type date, time, datetime2, or datetimeoffset. In SQL Server JDBC Driver 3.0, using those methods with those data types will cause an exception indicating that the conversion is not supported.

getObject Returns Date or Time Object

In the Microsoft SQL Server JDBC Driver 2.0, when you used SQLServerCallableStatement.getObject or SQLServerResultSet.getObject to retrieve a value of type date, time, datetime2, or datetimeoffset, an object of type java.lang.String was returned.

In the SQL Server JDBC Driver 3.0:

  • A value of type date will be returned as a java.sql.Date object.

  • A value of type time will be returned as a java.sql.Time object.

  • A value of type datetime2 will be returned as a java.sql.Timestamp object.

  • A value of type datetimeoffset will be returned as a microsoft.sql.DateTimeOffset object.

Column Behavior Change

SQLServerDatabaseMetaData.getColumns will return different values from previous versions of the driver for some columns in SQL Server JDBC Driver 3.0. See SQLServerDatabaseMetaData.getColumns for more information.

The following methods in SQLServerResultSetMetaData also have behavior changes:

Interfaces

The following interfaces are added:

For more information, see Wrappers and Interfaces.

Intention to Deprecate Class Constructors

In the SQL Server JDBC Driver 3.0 release, Microsoft announces its intention to deprecate in a future release the constructors in several classes. Microsoft does not want developers to directly instantiate instances of these types.

The constructors for these classes are not deprecated in the SQL Server JDBC Driver 3.0 release.

In the SQL Server JDBC Driver 3.0 release, the following classes have corresponding interfaces. If you need to access a driver-specific method or constant, use the interface instead of the class:

The constructors of the following classes will be deprecated in a future release and do not have corresponding interfaces because these classes do not expose SQL Server specific functions:

SQLServerDataSource.getReference No Longer Contains the Password or trustStorePassword

Prior to JDBC Driver 3.0, if SQLServerDataSource.setPassword was called on a SQLServerDataSource object, the password would be present in the object returned by SQLServerDataSource.getReference, allowing the object to be used to make additional connections. In JDBC Driver 3.0, you will need to set the password on the object returned by SQLServerDataSource.getReference before you make connections with the object.

Also, if you set SQLServerDataSource.setTrustStorePassword before binding the data source properties, you must call SQLServerDataSource.setTrustStorePassword before getting the connection. For more information, see SQLServerDataSource.getReference.

Sparse Column Support

The SQL Server JDBC Driver 3.0 supports sparse columns when you connect to a SQL Server 2008 (or later) server. For more information, see Sparse Columns.

Large User-Defined Types (UDTs)

Support has been added for UDTs larger than 8 kilobytes. For more information, see User Defined Types.

See Also

Other Resources

Overview of the JDBC Driver