Skip to content

mssql-jdbc:12.6.0.jre11 - 'sp_getapplock' expects parameter '@LockMode' #2323

@driverpt

Description

@driverpt

Driver version

Provide the JDBC driver version (e.g. 12.6.0.jre11).

SQL Server version

2017

Client Operating System

Docker

JAVA/JVM version

17

Table schema

N/A

Problem description

We're currently using Spring Boot w/ Flyway Migration (You can use TestContainers to debug the issue). We recently upgraded to 12.6.0-jre11 Driver and this caused Flyway to break.

The Query that Flyway uses seems to be fine, but probably something changed in the Driver Library that broke it.

Please check the link to the source code of the query.

Expected behavior

Flyway to execute

Actual behavior

Check Stack Trace

Error message/stack trace

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Procedure or function 'sp_getapplock' expects parameter '@LockMode', which was not supplied.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:261)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1752)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:657)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:576)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7739)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:4384)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:293)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:263)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.execute(SQLServerPreparedStatement.java:553)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java)
at org.flywaydb.core.internal.jdbc.JdbcTemplate.execute(JdbcTemplate.java:190)
at org.flywaydb.database.sqlserver.SQLServerApplicationLockTemplate.execute(SQLServerApplicationLockTemplate.java:59)
... 10 more

Procedure or function 'sp_getapplock' expects parameter '@LockMode', which was not supplied.
com.microsoft.sqlserver.jdbc.SQLServerException: Procedure or function 'sp_getapplock' expects parameter '@LockMode', which was not supplied.
at app//com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:261)
at app//com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1752)
at app//com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:657)
at app//com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:576)
at app//com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7739)
at app//com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:4384)
at app//com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:293)
at app//com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:263)
at app//com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.execute(SQLServerPreparedStatement.java:553)
at app//com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)
at app//com.zaxxer.hikari.pool.HikariProxyPreparedStatement.execute(HikariProxyPreparedStatement.java)
at app//org.flywaydb.core.internal.jdbc.JdbcTemplate.execute(JdbcTemplate.java:190)
at app//org.flywaydb.database.sqlserver.SQLServerApplicationLockTemplate.execute(SQLServerApplicationLockTemplate.java:59)
at app//org.flywaydb.database.sqlserver.SQLServerConnection.lock(SQLServerConnection.java:93)
at app//org.flywaydb.core.internal.schemahistory.JdbcTableSchemaHistory.create(JdbcTableSchemaHistory.java:104)
at app//org.flywaydb.core.Flyway.lambda$migrate$0(Flyway.java:199)
at app//org.flywaydb.core.FlywayExecutor.execute(FlywayExecutor.java:200)
at app//org.flywaydb.core.Flyway.migrate(Flyway.java:147)
at ####ifx.utils.Database.migrate(Database.kt:122)
at ####DatabaseTestBaseSimulatorTestDb.initTest(DatabaseTestBaseSimulatorTestDb.kt:12)
at [email protected]/java.lang.reflect.Method.invoke(Method.java:568)
at [email protected]/java.util.ArrayList.forEach(ArrayList.java:1511)
at [email protected]/java.util.ArrayList.forEach(ArrayList.java:1511)

Any other details that can be helpful

Source Code

Flyway Issue

JDBC trace logs

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in the driver. A high priority item that one can expect to be addressed quickly.

    Type

    No type

    Projects

    Status

    Closed Issues

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions