mssqllibR2DBC for SQL Server

Migration from io.r2dbc:r2dbc-mssql

Change the groupId and keep the artifact id r2dbc-mssql. Remove the other driver. Then fix the URL and decide whether large values stay buffered.

Dependency

Before
<groupId>io.r2dbc</groupId>
<artifactId>r2dbc-mssql</artifactId>
<version>1.0.7.RELEASE</version>
After
<groupId>org.mssqllib.r2dbc.mssql</groupId>
<artifactId>r2dbc-mssql</artifactId>
<version>1.0.1</version>

Gradle is the same coordinate change. A transitive copy of io.r2dbc:r2dbc-mssql still has to go. Both jars register a ConnectionFactoryProvider.

URL

Before
r2dbc:sqlserver://host/database
r2dbc:mssql://host/database
After
r2dbc:mssql://user:password@host:1433/database?materializeLobs=true

This provider accepts mssql only. It requires the port. SQL password login requires the user and password when no token source is set. Add materializeLobs=true when the application reads varchar(max), nvarchar(max), varbinary(max), or xml as String or byte[]. Without it those reads throw. Leave it off to take the streaming path.

Calls that differ

  • returnGeneratedValues throws UnsupportedOperationException. Select the new key with OUTPUT INSERTED.… in the statement text.
  • setAutoCommit sends SET IMPLICIT_TRANSACTIONS. isAutoCommit is true only when that mode is on and no transaction is open.
  • setTransactionIsolationLevel sends SET TRANSACTION ISOLATION LEVEL. The session starts at read committed. beginTransaction() keeps that session level. A begin that must name a different level uses beginTransaction(TransactionDefinition). Commit and rollback put the session level back.
  • setLockWaitTimeout sends SET LOCK_TIMEOUT. setStatementTimeout is a client deadline until the first response and fails with R2dbcTimeoutException when that response does not arrive.
  • releaseSavepoint succeeds and does not talk to the server. A null or empty name throws IllegalArgumentException. Create and rollback-to-savepoint do. createSavepoint with no transaction open turns auto-commit off and begins one.
  • A positive fetchSize opens a server cursor when the statement has at most one execution. Zero sends the statement directly. Confirm that a non-zero fetch size is still what you want.
  • Code that calls row.get after Result.map returns will run here. io.r2dbc:r2dbc-mssql 1.0.7 throws Value cannot be retrieved after row has been released. Move the read inside the callback if the code should stay portable.
  • SUM(int) and AVG(int) are still int on SQL Server and can raise 8115. Cast to bigint or use COUNT_BIG. A null Parameters.out for BIGINT is sent as an 8-byte integer.

Authentication

A SQL user and password keep working with the URL above. Entra login is configured with the options on the authentication page. Do not put a JWT in the URL. Integrated authentication, interactive authentication, and managed identity are not implemented. ActiveDirectoryPassword does not perform an Azure AD password grant.

After the switch

Log the PRELOGIN encryption line if a session that works on localhost hangs on Azure. Local servers usually drop TLS after login. Azure SQL keeps it. A short failure with error 40613 is a paused database. The default login budget retries it. See login retry.

Live comparisons against SQL Server and Azure SQL are in the sibling MsSqlTesting project, not in this repository. That suite can run the same case on this driver, on this driver with materializeLobs forced on, or on io.r2dbc:r2dbc-mssql.