R2DBC Driver for Microsoft SQL Server using TDS (Tabular Data Stream) Protocol
Clone or download
nebhale Remove Recursive Generics
This change removes the recursive generics from this implementation to be
compliant with changes made to the SPI.  These changes were driven by the
observation that recursive generics made consumption of the API harder and no
longer provided us much value.


Signed-off-by: Ben Hale <bhale@pivotal.io>
Latest commit ba8204f Jan 15, 2019


Reactive Relational Database Connectivity Microsoft SQL Server Implementation

This project contains the Microsoft SQL Server implementation of the R2DBC SPI. This implementation is not intended to be used directly, but rather to be used as the backing implementation for a humane client library to delegate to

This driver provides the following features:

  • Login with username/password with temporary SSL encryption
  • Full SSL encryption support (for e.g. Azure usage).
  • Transaction Control
  • Simple (un-cursored) execution of SQL batches
  • Execution of prepared statements
  • Execution of SQL cursored statements
  • Read support for all data types except binary types (BLOB)

Next steps:

  • Add encoding for remaining codecs (VARBINARY, XML, UDT)
  • Execution of stored procedures
  • Add support for TVP and UDTs


Both milestone and snapshot artifacts (library, source, and javadoc) can be found in Maven repositories.


Artifacts can bound found at the following repositories.


    <name>Spring Snapshots</name>
    <name>Spring Milestones</name>


Connection Factory Discovery:

ConnectionFactoryOptions options = builder()
    .option(DRIVER, "mssql")
    .option(HOST, "")
    .option(PORT, …)  // optional, defaults to 1433
    .option(USER, "")
    .option(PASSWORD, "")
    .option(DATABASE, "") // optional
    .option(SSL, true) // optional, defaults to false
    .option(Option.valueOf("applicationName"), "") // optional
    .option(Option.valueOf("connectionId"), new UUID(…)) // optional

ConnectionFactory connectionFactory = ConnectionFactories.get(options);

Mono<Connection> connectionMono = factory.create();


MssqlConnectionConfiguration configuration = MssqlConnectionConfiguration.builder()

MssqlConnectionFactory factory = new MssqlConnectionFactory(configuration);

Mono<MssqlConnection> connectionMono = factory.create();

Microsoft SQL Server uses named parameters that are prefixed with @. The following SQL statement makes use of parameters:

INSERT INTO person (id, first_name, last_name) VALUES(@id, @firstname, @lastname)

Parameters are referenced without the @ prefix when binding these:

connection.createStatement("INSERT INTO person (id, first_name, last_name) VALUES(@id, @firstname, @lastname)")
            .bind("id", 1)
            .bind("firstname", "Walter")
            .bind("lastname", "White")

Binding also allows positional index (zero-based) references. The parameter index is derived from the parameter discovery order when parsing the query.

Supported ConnectionFactory Discovery Options:

Core options:

  • driver: Must be mysql.
  • host: Server hostname to connect to.
  • port: Server port to connect to. Defaults to 1433.
  • username: Login username.
  • password: Login password.

Additional options:

  • applicationName: Name of the application. Defaults to driver name and version.
  • connectionId: Connection Id for tracing purposes. Defaults to a random Id.
  • connectTimeout: Connection Id for tracing purposes. Defaults to 30 seconds.
  • database: Initial database to select. Defaults to SQL Server user profile settings.
  • ssl: Whether to use transport-level encryption for the entire SQL server traffic, defaults to false.


This project is released under version 2.0 of the Apache License.