question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migration of SQL Server 2019 crashes when trying to determin database type

See original GitHub issue
Which version and edition of Flyway are you using?

7.6.0 Community

If this is not the latest version, can you reproduce the issue with the latest one as well? (Many bugs are fixed in newer releases and upgrading will often resolve the issue)
Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Java (JDK 1.8)

Which database are you using? (Type & version)

SQL Server 2019 (SQLEXPRESS)

Which operating system are you using?

Ubuntu 16.04 LTS

What did you do? (Please include the content causing the issue, any relevant configuration settings, the SQL statement(s) that failed (if any), and the command you ran)

I integrated flyway in the startup mechanism of my application (asix2 web service). The mechanism works correct with MySQL but when using MSSQL I get an SQLServerException when flyway tries to determine the database type.

Here the commands I use

      ClassLoader classLoader = serviceContext.getAxisService().getClassLoader();
      String dbLocation = configuration.getSqlConnectionString().startsWith(CommonStrings.SQL_MYSQL)
              ? "mysql"
              : "sqlserver";

      Flyway flyway = Flyway.configure(classLoader)
              .dataSource(configuration.getSqlConnectionString(), configuration.getSqlUsername(), configuration.getSqlPassword())
              .locations("filesystem:/var/lib/tomee/webapps/axis2/WEB-INF/classes/db/**/" + dbLocation, "db/migration")
              .baselineOnMigrate(true)
              .ignoreMissingMigrations(false)
              .load();
      flyway.repair();
      for (MigrationInfo i : flyway.info().pending()) {
        LOGGER.info("database migration task: " + i.getVersion() + " - " + i.getDescription() + " (script " + i.getScript() + ")");
      }
      flyway.migrate();

Because the used JDBC URL supports two database types

o.f.c.i.d.DatabaseTypeRegister - Multiple databases found that handle url 'jdbc:sqlserver://xxxxx;instanceName=SQLEXPRESS;DatabaseName=xxxx': Azure Synapse, SQL Server

Flyway tries first Synapse and sends an SQL statement to retrieve the server type. The issued statement SELECT SERVERPROPERTY('engineedition'); works in a query window and results in 4 (SQLEXPRESS) but there seems to be a bug in the jdbc driver from Microsoft.

I used the latest JDBS driver mssql-jdbc-9.2.1.jre8.jar but get the same result with older versions.

What did you expect to see?

The new Flyway history table in the used database and applied database scripts.

2021-03-11 10:52:29,985 DEBUG            o.f.c.i.s.c.ClassPathScanner - Scanning for classpath resources at 'classpath:db/callback' ...
2021-03-11 10:52:29,988 DEBUG            o.f.c.i.s.c.ClassPathScanner - Determining location urls for classpath:db/callback using ClassLoader org.apache.axis2.deployment.DeploymentClassLoader@61a28b48 ...
2021-03-11 10:52:30,003 DEBUG            o.f.c.i.s.c.ClassPathScanner - Unable to resolve location classpath:db/callback.
2021-03-11 10:52:30,012 INFO             o.f.c.i.license.VersionPrinter - Flyway Community Edition 7.6.0 by Redgate
2021-03-11 10:52:30,031 DEBUG            o.f.c.internal.util.FeatureDetector - AWS SDK available: false
2021-03-11 10:52:30,038 DEBUG            o.f.c.internal.util.FeatureDetector - Google Cloud Storage available: false
2021-03-11 10:52:30,038 DEBUG            o.f.c.i.s.c.ClassPathScanner - Scanning for classpath resources at 'classpath:db/migration' ...
2021-03-11 10:52:30,039 DEBUG            o.f.c.i.s.c.ClassPathScanner - Determining location urls for classpath:db/migration using ClassLoader org.apache.axis2.deployment.DeploymentClassLoader@61a28b48 ...
2021-03-11 10:52:30,046 DEBUG            o.f.c.i.s.c.ClassPathScanner - Scanning URL: jar:file:/tmp/tomee-tomee-tmp/axis2-tmp-2080985808203590681.tmp/axis22897995310274879448CustomLicensingAdapter.aar!/db/migration
2021-03-11 10:52:30,047 DEBUG            o.f.c.internal.util.FeatureDetector - JBoss VFS v2 available: false
2021-03-11 10:52:30,072 DEBUG            o.f.c.i.s.c.ClassPathScanner - Found resource: db/migration/
2021-03-11 10:52:30,072 DEBUG            o.f.c.i.s.c.ClassPathScanner - Found resource: db/migration/V2__existing_containers.class
2021-03-11 10:52:30,072 DEBUG            o.f.c.i.s.c.ClassPathScanner - Scanning for classes at classpath:db/migration
2021-03-11 10:52:30,080 DEBUG            o.f.core.internal.util.ClassUtils - Found class: db.migration.V2__existing_containers
2021-03-11 10:52:30,084 DEBUG            o.f.c.i.s.f.FileSystemScanner - Scanning for filesystem resources at '/var/lib/tomee/webapps/axis2/WEB-INF/classes/db'
2021-03-11 10:52:30,084 DEBUG            o.f.c.i.s.f.FileSystemScanner - Scanning for resources in path: /var/lib/tomee/webapps/axis2/WEB-INF/classes/db (/var/lib/tomee/webapps/axis2/WEB-INF/classes/db)
2021-03-11 10:52:30,085 DEBUG            o.f.c.i.s.f.FileSystemScanner - Scanning for resources in path: /var/lib/tomee/webapps/axis2/WEB-INF/classes/db/sqlserver (/var/lib/tomee/webapps/axis2/WEB-INF/classes/db)
2021-03-11 10:52:30,085 DEBUG            o.f.c.i.s.f.FileSystemScanner - Scanning for resources in path: /var/lib/tomee/webapps/axis2/WEB-INF/classes/db/mysql (/var/lib/tomee/webapps/axis2/WEB-INF/classes/db)
2021-03-11 10:52:30,093 DEBUG            o.f.c.i.s.f.FileSystemScanner - Found filesystem resource: /var/lib/tomee/webapps/axis2/WEB-INF/classes/db/sqlserver/V0__initial_schema.sql
2021-03-11 10:52:30,094 DEBUG            o.f.c.i.s.f.FileSystemScanner - Found filesystem resource: /var/lib/tomee/webapps/axis2/WEB-INF/classes/db/sqlserver/V1__firmcode_and_cmactid_of_container.sql

What did you see instead?
 com.microsoft.sqlserver.jdbc.SQLServerException: The "variant" data type is not supported.
	at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170)
	at com.microsoft.sqlserver.jdbc.TypeInfo.setFromTDS(dtv.java:1670)
	at com.microsoft.sqlserver.jdbc.StreamColumns.setFromTDS(StreamColumns.java:47)
	at com.microsoft.sqlserver.jdbc.SQLServerResultSet$1CursorInitializer.onColMetaData(SQLServerResultSet.java:196)
	at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:77)
	at com.microsoft.sqlserver.jdbc.SQLServerResultSet.<init>(SQLServerResultSet.java:295)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1465)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:388)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:338)
	at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4026)
	at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1416)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:185)
	at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:160)
	at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:281)
	at org.flywaydb.core.internal.jdbc.JdbcTemplate.queryForInt(JdbcTemplate.java:145)
	at org.flywaydb.core.internal.database.sqlserver.synapse.SynapseDatabaseType.handlesDatabaseProductNameAndVersion(SynapseDatabaseType.java:46)
	at org.flywaydb.core.internal.database.DatabaseTypeRegister.getDatabaseTypeForConnection(DatabaseTypeRegister.java:171)
	at org.flywaydb.core.internal.jdbc.JdbcConnectionFactory.<init>(JdbcConnectionFactory.java:71)
	at org.flywaydb.core.Flyway.execute(Flyway.java:507)
	at org.flywaydb.core.Flyway.repair(Flyway.java:437)
...
SEVERE - ConnectionID:3: getNextResult: Encountered unexpected unknown token (0x49)
SEVERE - ConnectionID:3 got unexpected value in TDS response at offset:10
[INFO] org.apache.axis2.AxisFault: 
Unable to determine database engine edition.'
---------------------------------------------
SQL State  : 08S01
Error Code : 0
Message    : The "variant" data type is not supported.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
JoergJanscommented, Mar 11, 2021

Stop, wait a minute. It seems there really is an older version of the jdbc driver in the library path. I’ll check this out.

Sorry for that. Thanks for your support.

0reactions
DoodleBobBuffPantscommented, Mar 11, 2021

Having tested this version of the driver, I am unable to reproduce this. Are you able to reproduce this with the command-line, and could you share a minimal reproduction project?

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL Server 2019 crashed: how to detect the reason?
Check the SQL Server error log. The SQL Server 2019 default location is C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Log.
Read more >
Problems Using Microsoft SQL Server Migration Assistant for ...
I'm having some issues using SSMA for Access and I can't figure out what is going on. The database in question is an...
Read more >
Common Issues with the SQL Server Import and Export Wizard
The SQL Server Import and Export Wizard is a useful tool for copying data from one data source (e.g. a SQL Server database...
Read more >
SQL Server Crashes When Hitting 80 Percent RAM Usage
I recently ran into a situation where a new SQL Server would crash hard every time it would get under a load.
Read more >
ssma - Why SQL Server Migration Assistant keeps crashing on ...
One more thing that helped me in addition to setting affinity to Core 0 only: SSMA stopped crashing after I set Parallel Data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found