My Open Liberty application doesn't connect to the database. How do I debug the connection settings.
For example the connection fails with:
[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
The comment from Scott Kurz is so brilliant, it should get it's own post:
If you'd like to verify if the Liberty server config is actually what you expect it to be:
See this blog: https://openliberty.io/blog/2019/09/13/testing-database-connections-REST-APIs.html
You need
<feature>restConnector-2.0</feature>
and an admin user (if you don't have one), e.g.
<quickStartSecurity userName="Bob" userPassword="bobpwd" />
Now you can see your DB-config: http://localhost:9080/ibm/api/config/dataSource/todoListDS.
For postgres it should look like this:
{
"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"
]
}