как отлаживать проблемы с источниками данных Open Liberty

Мое приложение Open Liberty не подключается к базе данных. Как отлаживать настройки подключения.

Например, соединение завершается ошибкой:


[INFO] Caused by: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.8.v20201217-ecdf3c32c4): org.eclipse.persistence.exceptions.DatabaseException
[INFO] Internal Exception: java.sql.SQLException: The server requested password-based authentication, but no password was provided. DSRA0010E: SQL State = 08004, Error Code = 0
[INFO] Error Code: 0

person Ich    schedule 29.06.2021    source источник


Ответы (1)


Комментарий от Скотта Курца настолько великолепен , он должен получить свой собственный пост:

Если вы хотите проверить, действительно ли конфигурация сервера Liberty соответствует вашим ожиданиям:

См. этот блог: https://openliberty.io/blog/2019/09/13/testing-database-connections-REST-APIs.html

Тебе нужно

<feature>restConnector-2.0</feature> 

и пользователь-администратор (если у вас его нет), например.

<quickStartSecurity userName="Bob" userPassword="bobpwd" /> 

Теперь вы можете увидеть свою конфигурацию БД: http://localhost:9080/ibm/api/config/dataSource/todoListDS.

Для postgres это должно выглядеть так:

{
   "configElementName": "dataSource",
   "uid": "jpadatasource",
   "id": "jpadatasource",
   "jndiName": "jpadatasource",
   "beginTranForResultSetScrollingAPIs": true,
   "beginTranForVendorAPIs": true,
   "connectionSharing": "MatchOriginalRequest",
   "enableConnectionCasting": false,
   "jdbcDriverRef": {
      "configElementName": "jdbcDriver",
      "uid": "dataSource[jpadatasource]/jdbcDriver[default-0]",
      "libraryRef": {
         "configElementName": "library",
         "uid": "postgresql-driver",
         "id": "postgresql-driver",
         "apiTypeVisibility": "spec,ibm-api,api,stable",
         "filesetRef": [
            {
               "configElementName": "fileset",
               "uid": "library[postgresql-driver]/fileset[default-0]",
               "caseSensitive": true,
               "dir": "/Users/d067570/SAPDevelop/gh/ciaas/api/target/liberty/wlp/usr/shared/resources/",
               "excludes": "",
               "includes": "postgresql-*.jar",
               "scanInterval": 0
            }
         ]
      }
   },
   "statementCacheSize": 10,
   "syncQueryTimeoutWithTransactionTimeout": false,
   "transactional": true,
   "properties.postgresql": {
      "databaseName": "postgres",
      "password": "******",
      "portNumber": 5432,
      "preparedStatementCacheQueries": 0,
      "serverName": "localhost",
      "user": "postgres"
   },
   "api": [
      "/ibm/api/validation/dataSource/jpadatasource"
   ]
}
person Ich    schedule 29.06.2021