Skip to content

Commit

Permalink
Optimize the message of DatabaseServerInfo (#28428)
Browse files Browse the repository at this point in the history
* Optimize the message of `DatabaseServerInfo`

* Fix message from DBMS to Database type

* Fix databaseName to databaseType
  • Loading branch information
134130 committed Sep 15, 2023
1 parent c865d03 commit 871cedb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
@Getter
public final class DatabaseServerInfo {

private final String databaseName;
private final String databaseType;

private final String databaseVersion;

public DatabaseServerInfo(final DataSource dataSource) {
try (Connection connection = dataSource.getConnection()) {
DatabaseMetaData databaseMetaData = connection.getMetaData();
databaseName = databaseMetaData.getDatabaseProductName();
databaseType = databaseMetaData.getDatabaseProductName();
databaseVersion = databaseMetaData.getDatabaseProductVersion();
} catch (final SQLException ex) {
throw new DatabaseServerLoadingServerException(ex);
Expand All @@ -47,6 +47,6 @@ public DatabaseServerInfo(final DataSource dataSource) {

@Override
public String toString() {
return String.format("Database name is `%s`, version is `%s`", databaseName, databaseVersion);
return String.format("Database type is `%s`, version is `%s`", databaseType, databaseVersion);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ void assertToString() throws SQLException {
when(databaseMetaData.getDatabaseProductName()).thenReturn("fixtureDB");
when(databaseMetaData.getDatabaseProductVersion()).thenReturn("1.0.0");
when(dataSource.getConnection().getMetaData()).thenReturn(databaseMetaData);
assertThat(new DatabaseServerInfo(dataSource).toString(), is("Database name is `fixtureDB`, version is `1.0.0`"));
assertThat(new DatabaseServerInfo(dataSource).toString(), is("Database type is `fixtureDB`, version is `1.0.0`"));
}
}

0 comments on commit 871cedb

Please sign in to comment.