Announcing the JDBC Driver 6.0 for SQL Server


We are pleased to announce the release of the Microsoft JDBC Driver 6.0 for SQL Server! Like the preview drivers, it brings support for:

  • Always Encrypted
  • Azure Active Directory authentication
  • Table-Valued Parameters
  • Internationalized Domain Names (IDN)
  • Extended support for Parameterized Queries
  • Transparent connections to AlwaysOn Availability Groups

The JDBC Driver 6.0 for SQL Server is fully compliant with JDBC specifications 4.1 and 4.2. The jars contained in the 6.0 package are named according to their compliance with the JDBC API version. For example, the sqljdbc42.jar file from the 6.0 package is JDBC API 4.2 compliant. Similarly, the sqljdbc41.jar file is compliant with JDBC API 4.1.

To ensure you have the right sqljdbc42.jar or sqljdbc41.jar, run the following lines of code. If the output is “Driver version: 6.0.7507.100“, you have the JDBC Driver 6.0 package.
Connection conn = DriverManager.getConnection("jdbc:sqlserver://<server>;user=<user>;password=<password>;");
System.out.println("Driver version: " + conn.getMetaData().getDriverVersion());

Read the full release announcement here.

Learn how to pick which jar file is right for you here and read more documentation here.

Andrea Lam (andrela@microsoft.com)

Comments (8)

  1. rmcdonough says:

    Will these drivers every be published to Maven Central or JCenter on Bintray? Not having these drivers available in public repositories is annoying since the majority of projects are using a dependency manager such as Maven, Gradle, or Ivy. It forces teams to have to go through the minutia of downloading the driver and manually adding to a local repo or adding a local dependency.

    1. Andrea Lam says:

      Hi Ryan,

      Thanks for the feedback. We have heard multiple requests for hosting on Maven and will take this into consideration for our following releases. Please stay tuned.

      Thanks,
      Andrea Lam
      Program Manager
      andrela@microsoft.com

  2. Hi Andrea,

    I noticed that this driver is still not supporting sql_variant data type. Are you planning on adding support for the sql_variant data type? If so, can you share a timeframe?

  3. stole says:

    Just a suggestion: would it be possible to use the SQLServerDataTable class to pass the sqlType. That way we could use this nicely in spring:
    NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
    final String sql = “{call dbo.UpdateMsDriverTest(:data)}”;

    SQLServerDataTable dataTable = new SQLServerDataTable();
    dataTable.setSqlType(“dbo.TheSqlDataType”);
    dataTable.addColumnMetadata(“ThisId”, Types.INTEGER);
    dataTable.addColumnMetadata(“ThatId”, Types.SMALLINT);

    dataTable.addRow(2, 1);
    dataTable.addRow(2, 2);

    final MapSqlParameterSource source = new MapSqlParameterSource();
    source.addValue(“data”, dataTable);

    jdbcTemplate.update(sql, source);

    Of course it would require some minor fixes in the driver code (TVP class mainly).

  4. stole says:

    Also there seems to be a bug if the sql type is not in dbo scheme:
    –SQL

    CREATE SCHEMA tableValued

    CREATE TYPE [tableValued].[TheSqlDataType] AS TABLE
    (ThisId int, ThatId smallint)

    CREATE TABLE [tableValued].[RealTable] (
    [ThisId] integer NOT NULL,
    [ThatId] smallint NOT NULL
    )

    CREATE PROCEDURE [tableValued].[UpdateMsDriverTest]
    @InputData tableValued.TheSqlDataType READONLY
    AS
    BEGIN
    MERGE INTO [tableValued].[RealTable] AS target
    USING @InputData AS source
    ON target.ThisId = source.ThisId
    WHEN MATCHED THEN
    UPDATE SET
    ThatId = source.ThatId
    WHEN NOT MATCHED THEN
    INSERT
    (ThisId, ThatId)
    VALUES
    (source.ThisId, source.ThatId);
    END
    –END SQL

    //Java code
    Connection connection = …;

    final String sql = “{call tableValued.UpdateMsDriverTest(?)}”;

    SQLServerDataTable dataTable = new SQLServerDataTable();
    dataTable.addColumnMetadata(“ThisId”, Types.INTEGER);
    dataTable.addColumnMetadata(“ThatId”, Types.SMALLINT);

    dataTable.addRow(2, 1);
    dataTable.addRow(2, 2);

    SQLServerPreparedStatement pStmt = (SQLServerPreparedStatement)connection.prepareStatement(sql);

    pStmt.setStructured(1, “tableValued.TheSqlDataType”, dataTable);
    pStmt.execute();

    fails with:
    com.microsoft.sqlserver.jdbc.SQLServerException: Column, parameter, or variable #1: Cannot find data type TheSqlDataType.

  5. dilbert says:

    Why don’t you opensource the driver?

  6. Pierre Souchay says:

    Unfortunately, the JavaKerberos authentication still does not work for Cross-Realms (it uses still not Kerberos authentication with CrossDomain (it uses default_realm for realm for Cross-Domain).

    Do you plan to fix this ?

  7. David Bryant says:

    Why were the setStructured() methods removed from the ISQLServerPreparedStatement interface between the preview and final versions of the driver. They are now only defined on the SQLServerPreparedStatement class as final methods, which makes them somewhat painful to mock for unit testing.

Skip to main content