Search code examples
quarkusquarkus-panache

Unable to connect to SQL Server using the quarkus-hibernate-reactive due to incorrect reactive.url


I had worked on Quarkus connecting to Postgres. But this is the first time I am trying to connect to SQL Server, which is the default server in my current project. I am following this guide to create a database component.

The properties file contains the following:

quarkus.datasource.db-kind=mssql 
quarkus.datasource.username=<user-id>
quarkus.datasource.password=<pwd>

quarkus.datasource.reactive.url=sqlserver://localhost:1433/<db-name>?currentSchema=<schema-name>
quarkus.datasource.reactive.max-size=20 
hibernate.default_schema=<schema-name>

The application starts fine, but when I make a request to the Resource that internally uses the repository, I get the following error:

Internal Server Error

Error id f0a959d2-3201-4015-bfd7-6628ae9914d1-1, io.vertx.mssqlclient.MSSQLException: {number=208, state=1, severity=16, message='Invalid object name ''.', serverName='<sql-instance>', lineNumber=1, additional=[io.vertx.mssqlclient.MSSQLException: {number=8180, state=1, severity=16, message='Statement(s) could not be prepared.', serverName='<sql-instance>', lineNumber=1}]}

This means, my application is able to connect to the database, but it is not able to find the table. The table exists in a schema, and I am unable to pass the schema which may be the cause of the issue. If you check the properties file, I have tried with two options:

  • Adding 'currentSchema' as a query param
  • Adding the property 'hibernate.default_schema'

But none of the two options are working. There is no documentation on SQL Server that can help me provide the right configuration to the Quarkus application. Please help.


Solution

  • The correct property is quarkus.hibernate-orm.database.default-schema It is possible to check all the available configuration properties in this url https://quarkus.io/guides/hibernate-orm#hibernate-configuration-properties