spring-bootspring-data-jpahikaricp

How to fix Wrong user name or password at HikariPool initialization


I got the following exception during spring boot (v 3.1.4) startup in a unit test:

HikariPool-1 - Exception during pool initialization. org.h2.jdbc.JdbcSQLInvalidAuthorizationSpecException: Wrong user name or password

My configuration looks like this:

spring:
  flyway:
    enabled: false
  datasource:
    url: jdbc:h2:mem:testdb
    driverClassName: org.h2.Driver
    username: sa
    password: 
  h2:
    console:
      enabled: true
      path: /h2-console
  jpa:
    database: h2
    show-sql: true
    hibernate:
      ddl-auto: create-drop
    properties:
      hibernate:
        connection:
          url: "jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;NON_KEYWORDS=key"
        dialect: org.hibernate.dialect.H2Dialect

Hibernate is able to auto create some tables before this exception occurs. Any hint what configuration is missing?


Solution

  • The following setting fixed the error:

    spring:
      datasource:
        url: jdbc:h2:~/testdb