Skip to content

Commit

Permalink
Add more db information to the site information page. (#7403)
Browse files Browse the repository at this point in the history
* Add more db information to the site information page.
db product and version, driver product and version
db username, schema and database used.

* Changed db.product to db.type and remove DB from labels

* Capitalize U in Usename

* Update db properties to support cases with mismatch drivers that throw AbstractMethodError
  • Loading branch information
ianwallen authored Nov 15, 2023
1 parent 1b42898 commit 01e2467
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,21 @@ private void loadDatabaseInfo(ServiceContext context) throws SQLException {
connection = context.getBean(DataSource.class).getConnection();
dbURL = connection.getMetaData().getURL();
databaseProperties.put("db.openattempt", "Database Opened Successfully");
try {
databaseProperties.put("db.type", connection.getMetaData().getDatabaseProductName());
databaseProperties.put("db.version", connection.getMetaData().getDatabaseProductVersion());
databaseProperties.put("db.driver", connection.getMetaData().getDriverName());
databaseProperties.put("db.driverVersion", connection.getMetaData().getDriverVersion());
databaseProperties.put("db.username", connection.getMetaData().getUserName());
databaseProperties.put("db.name", connection.getCatalog());
// Put "db.schema" field last as getSchema() has a known issues with the jetty jndi h2 drivers which is most likely related to a driver mismatch issue.
// Receiver class org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper does not define or inherit an implementation of the resolved method 'abstract java.lang.String getSchema()' of interface java.sql.Connection.
databaseProperties.put("db.schema", connection.getSchema());
} catch (AbstractMethodError e) {
// Most likely driver mismatch
// https://stackoverflow.com/questions/17969365/why-i-am-getting-java-lang-abstractmethoderror-errors
Log.warning(Geonet.GEONETWORK, "Failed to get db properties. " + e.getMessage());
}

if (connection instanceof BasicDataSource) {
BasicDataSource basicDataSource = (BasicDataSource) connection;
Expand Down
7 changes: 7 additions & 0 deletions web-ui/src/main/resources/catalog/locales/en-admin.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,13 @@
"db.numidle": "Available connections",
"db.openattempt": "Status",
"db.url": "JDBC URL",
"db.type": "Type",
"db.version": "Version",
"db.driver": "JDBC Driver",
"db.driverVersion": "JDBC Driver Version",
"db.username": "Username",
"db.schema": "Schema",
"db.name": "Name",
"dbInformation": "Database",
"dbUrl": "Database",
"defineCatalogLogo": "Define the logo to use for the catalog",
Expand Down

0 comments on commit 01e2467

Please sign in to comment.