r/SQLServer • u/nicholasbradfield • 5h ago
Community Share new R2DBC-MSSQL driver with FedAuth
new R2DBC-MSSQL driver with FedAuth
https://www.mssqllib.org
mssqllib is a public-domain R2DBC driver for Microsoft SQL Server. It speaks TDS over JDK NIO sockets and Reactor. It does not use Netty.
The Maven artifact is r2dbc-mssql. The driver id is mssql, and the URL scheme is r2dbc:mssql://. It needs Java 17 and implements io.r2dbc:r2dbc-spi:1.0.0.RELEASE.
| groupId | org.mssqllib.r2dbc.mssql |
|---|---|
| artifactId | r2dbc-mssql |
| version | 1.0.3 |
| Java package | org.mssqllib.r2dbc.mssql |
| Provider | org.mssqllib.r2dbc.mssql.TdsConnectionFactoryProvider |
| JPMS module | org.tdslib.r2dbc.mssql |
What it is
This is a new TDS implementation. It is not a fork of io.r2dbc:r2dbc-mssql, and it is not an upstream of that driver. It is not affiliated with Microsoft or with the R2DBC project.
The artifact id is intentional. A groupId and version change is what substitutes this jar for io.r2dbc:r2dbc-mssql. Do not put both jars on one classpath. Both register io.r2dbc.spi.ConnectionFactoryProvider.
Two login paths are implemented: SQL username and password, and federated authentication for Microsoft Entra (Azure SQL and SQL Server with Entra authentication). The driver acquires a client-credentials token with the JDK HTTP client. It does not depend on MSAL, and it does not read the process environment.
Status
Version 1.0.3 is on Maven Central. See https://www.mssqllib.org/install.html and https://www.mssqllib.org/project.html.
Two ways to read large values
The default leaves materializeLobs false. varchar(max), nvarchar(max), varbinary(max), and xml are then a live Clob or Blob. The integration suite calls this unrestricted mode. io.r2dbc:r2dbc-mssql 1.0.7 buffers each of those values before it emits the row.
materializeLobs=true is the compatibility setting. It buffers those values and accepts String and byte[] inside Result.map, which is how code written for io.r2dbc:r2dbc-mssql reads them. There is no separate option named compat. The testing profile compat=true sets materializeLobs.
Performance
Initial testing shows roughly twice the performance of io.r2dbc:r2dbc-mssql. The project attributes that gap, and the streaming behavior, to the JDK NIO design. The other driver is built on Netty. This repository does not include the benchmark program, so the factor is an initial result, not a guaranteed ratio. The mechanism is on the https://www.mssqllib.org/architecture.html page.