Uploaded image for project: 'Agroal'
  1. Agroal
  2. AG-298

Spring Boot health check database entry is always UNKNOWN even for correctly configured datasources

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 2.8, 3.0
    • spring
    • None

      https://github.com/agroal/agroal/blob/a8813c95200f91e51679a1956344adc7aa212414/agroal-spring-boot-starter/src/main/java/io/agroal/springframework/boot/health/AgroalDataSourceHealthIndicator.java#L26

      The above line is making the database name in the health details to be `UNKNOWN` always for correct datasource configurations where URL is absent/non-standard. A mainstream case for this is the DB2 driver, you can use `jdbc-url` to configure it BUT you can avoid configuring `jdbc-url` and configure the connection via other properties instead, see an example without jdbc-url: 

      # application.yml
      spring:
        datasource:
          agroal:
            primary:
              driver-class-name: com.ibm.db2.jcc.DB2Driver
              username: myuser
              password: mypassword
              min-size: 2
              max-size: 10
              initial-size: 2
              connection-factory-configuration:
                # No jdbcUrl here — DB2 driver properties instead
                connection-provider-class-name: com.ibm.db2.jcc.DB2SimpleDataSource
                jdbc-properties:
                  serverName: db2server.inditex.grp
                  portNumber: 50000
                  databaseName: MYDB
                  driverType: 4
                  currentSchema: MYSCHEMA
                  sslConnection: true

      The same code can bee seen both in 2.8 and 3.0 tags.

      As you can see the datasource will work but no jdb-url property is set. 

      I can contribute a PR to fix this.

              lbarreiro-1 Luis Barreiro
              juliojgd Julio Gomez Diaz
              Julio Gomez Diaz
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: