Describe the bug
Unable to connect to MSSQL server database using hibernate-orm
Expected behavior
Should be able to connect to MSSQL server database when the application is run
Actual behavior
The following error takes place when the application is run with MMSQL server config in application properties,
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.persistenceException(FastBootEntityManagerFactoryBuilder.java:110)
at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:70)
at io.quarkus.hibernate.orm.runtime.FastBootHibernatePersistenceProvider.createEntityManagerFactory(FastBootHibernatePersistenceProvider.java:54)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:80)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at io.quarkus.hibernate.orm.runtime.JPAConfig$LazyPersistenceUnit.get(JPAConfig.java:110)
at io.quarkus.hibernate.orm.runtime.JPAConfig.startAll(JPAConfig.java:58)
at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder.startAllPersistenceUnits(HibernateOrmRecorder.java:84)
at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits38.deploy_0(HibernateOrmProcessor$startPersistenceUnits38.zig:70)
at io.quarkus.deployment.steps.HibernateOrmProcessor$startPersistenceUnits38.deploy(HibernateOrmProcessor$startPersistenceUnits38.zig:36)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:195)
... 12 more
Caused by: org.hibernate.exception.SQLGrammarException: Unable to open JDBC Connection for DDL execution
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:103)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactionIsolatorJtaImpl.<init>(DdlTransactionIsolatorJtaImpl.java:62)
at org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl.buildDdlTransactionIsolator(JtaTransactionCoordinatorBuilderImpl.java:46)
at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.getDdlTransactionIsolator(HibernateSchemaManagementTool.java:175)
at org.hibernate.tool.schema.internal.HibernateSchemaManagementTool.buildGenerationTargets(HibernateSchemaManagementTool.java:135)
at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:110)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:145)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:73)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:314)
at io.quarkus.hibernate.orm.runtime.boot.FastBootEntityManagerFactoryBuilder.build(FastBootEntityManagerFactoryBuilder.java:68)
... 21 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'sa'. ClientConnectionId:cf605615-24b3-47ff-97c0-9654662fc5c1
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:262)
at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:258)
at com.microsoft.sqlserver.jdbc.TDSParser.parse(tdsparser.java:104)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:5036)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3668)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:94)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3627)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7194)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2935)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2456)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2103)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1950)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1162)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:735)
at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:200)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:390)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:372)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:65)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1126)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
To Reproduce
Steps to reproduce the behavior:
Configuration
# Add your application.properties here, if applicable.
quarkus.datasource.db-kind=mssql
quarkus.datasource.username=sa
quarkus.datasource.password=password
quarkus.datasource.jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
quarkus.datasource.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=db_name
quarkus.hibernate-orm.dialect=org.hibernate.dialect.SQLServer2012Dialect
Screenshots
(If applicable, add screenshots to help explain your problem.)
Environment (please complete the following information):
uname -a or ver: Linux pc 4.15.0-1081-oem #91-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linuxjava -version: openjdk version "11.0.7" mvnw --version or gradlew --version): Apache Maven 3.6.3Additional context
/cc @gsmet, @Sanne
Hmmm, I fail to see it as a Quarkus issue? It says you cannot log in with the user sa.
sa is the username in the MSSQL database. When I try running the quarkus application with MSSQL config in application.properties I get the error. I tried logging in the MSSQL server via sqlcmd in cli using the same credentials defined in application.properties and was successful.
This is the application.properties for MSSQL server that I used for the quarkus application,
quarkus.datasource.db-kind=mssql
quarkus.datasource.username=sa
quarkus.datasource.password=password
quarkus.datasource.jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
quarkus.datasource.jdbc.url=jdbc:sqlserver://localhost:1433;databaseName=db_name
quarkus.hibernate-orm.dialect=org.hibernate.dialect.SQLServer2012Dialect
This happens only when I tried connecting to MSSQL database and when I tried to run the application with other databases such as MySQL, MariaDB and PostgreSQL it works fine.
hi, are you sure you can connect with non-Quarkus applications with the same credentials?
Last time I used it, it would refuse to authenticate when using trivial passwords.
We have integration tests covering specifically for this so I would ask you to double check your setup please.
@Sanne the password mentioned is a sample password. I tried logging into MSSQL using in cli using sqlcmd -U sa -S localhost -P 'password' with the same credentials used in the quarkus application and it is working fine.
@Sanne Also, I'm able to connect to MSSQL database with same credentials using JDBC mssql-jdbc but when I try the same using hibernate-orm it fails.
Very odd. Do you think you could have a look at the integration test we have here:
Can you manage to edit it to figure out what exactly is different in the IT we have compared to your app?
@Sanne I'm able to connect to the MSSQL database from quarkus once I updated the password. Seems the password I have used earlier does not satisfy the complexity required. Thanks a lot for helping out.