Upravit

Sdílet prostřednictvím


JDBC 4.2 compliance for the JDBC driver

Download JDBC driver

Note

Versions prior to Microsoft JDBC Driver 4.2 for SQL Server are compliant for Java Database Connectivity API 4.0 specifications. This section does not apply for versions prior to the 4.2 release.

The Java Database Connectivity API 4.2 specification is supported by the Microsoft JDBC Driver 4.2 for SQL Server, with the following API methods.

SQLServerStatement class

New Methods Description Noteworthy Implementation
long[] executeLargeBatch() Executes batch where returned update counts can be long. Implemented as described in the java.sql.Statement interface. For more information, see java.sql.Statement.
long executeLargeUpdate(String sql)

long executeLargeUpdate(String sql, int autoGeneratedKeys)

long executeLargeUpdate(String sql, int[] columnIndexes)

executeLargeUpdate(String sql, String[] columnNames)
Executes a DML/DDL statement where returned update counts can be long. There are 4 new (overloaded) methods to support long update count. Implemented as described in the java.sql.Statement interface. For more information, see java.sql.Statement.
long getLargeMaxRows() Retrieves the maximum number of rows as a long value that the ResultSet can contain. SQL Server only supports integer limits for max rows. For more information, see java.sql.Statement.
long getLargeUpdateCount() Retrieves the current result as a long update count. SQL Server only supports integer limits for max rows. For more information, see java.sql.Statement.
void setLargeMaxRows(long max) Sets the maximum number of rows as a long value that the ResultSet can contain. SQL Server only supports integer limits for max rows. This method throws a not supported exception if greater than max integer size is passed as the parameter. For more information, see java.sql.Statement.

SQLServerCallableStatement class

New Methods Description Noteworthy Implementation
void registerOutParameter(int parameterIndex, SQLType sqlType)

void registerOutParameter(int parameterIndex, SQLType sqlType, int scale)

void registerOutParameter(int parameterIndex, SQLType sqlType, String typeName)

void registerOutParameter(String parameterName, SQLType sqlType)

void registerOutParameter(String parameterName, SQLType sqlType, int scale)

registerOutParameter(String parameterName, SQLType sqlType, String typeName)
Registers the OUT parameter. There are 6 new (overloaded) methods to support the new SQLType interface. Implemented as described in the java.sql.CallableStatement interface. For more information, see java.sql.CallableStatement.
void setObject(String parameterName, Object x, SQLType targetSqlType)

void setObject(String parameterName, Object x, SQLType targetSqlType, int scaleOrLength)
Sets the value of the parameter with the given object. There are 2 new (overloaded) methods to support the new SQLType interface Implemented as described in the java.sql.CallableStatement interface. For more information, see java.sql.CallableStatement.

SQLServerPreparedStatement class

New Methods Description Noteworthy Implementation
long executeLargeUpdate() Execute DML/DDL statement and return long update count Implemented as described in the java.sql.PreparedStatement interface. For more information, see java.sql.PreparedStatement.
void setObject(int parameterIndex, Object x, SQLType targetSqlType)

void setObject(int parameterIndex, Object x, SQLType targetSqlType, int scaleOrLength)
Sets the value of the parameter with the given object. There are 2 new (overloaded) methods to support the new SQLType interface. Implemented as described in the java.sql.PreparedStatement interface. For more information, see java.sql.PreparedStatement.

SQLServerDatabaseMetaData class

New Methods Description Noteworthy Implementation
long getMaxLogicalLobSize() Retrieves the maximum number of bytes this database allows for the logical size for a LOB. For SQL Server, this value is 2^31-1. For more information, see java.sql.DatabaseMetaData.
boolean supportsRefCursors() Retrieves whether this database supports REF CURSOR. Returns false as SQL Server doesn't support REF CURSOR. For more information, see java.sql.DatabaseMetaData.

SQLServerResultSet class

New Methods Description Noteworthy Implementation
Updates the specified column with an Object value. There are 4 new (overloaded) methods to support the new SQLType interface. Implemented as described in the java.sql.ResultSet interface. For more information, see java.sql.ResultSet.

The Java Database Connectivity API 4.2 specification is supported by the Microsoft JDBC Driver 4.2 for SQL Server, with the following Data Type Mappings.

New Data Type Mappings Description
New Java classes in Java 8:

LocalDate/LocalTime/LocalDateTime

OffsetTime/OffsetDateTime

New JDBC types:

TIME_WITH_TIMEZONE

TIMESTAMP_WITH_TIMEZONE

REF_CURSOR
REF_CURSOR isn't supported in SQL Server. Driver throws a SQLFeatureNotSupportedException exception if this type is used. The driver supports all other new Java and JDBC type mappings as specified in the JDBC 4.2 specification.