Connection から取得できる情報は次のとおりです。
Connection dbConnection = null;
try {
dbConnection = dataSource.getConnection();
DatabaseMetaData dbMetaData = dbConnection.getMetaData();
getLogger().debug("DB Product Name = " + dbMetaData.getDatabaseProductName());
getLogger().debug("DB Product Version= " + dbMetaData.getDatabaseProductVersion());
getLogger().debug("DB Driver Name = " + dbMetaData.getDriverName());
getLogger().debug("DB Driver Version = " + dbMetaData.getDriverVersion());
getLogger().debug("DB Username = " + dbMetaData.getUserName());
getLogger().debug("DB URL = " + dbMetaData.getURL());
} catch (Exception e) {
getLogger().debug("Failed to recover DatabaseMetaData: "+e.getMessage(), e);
} finally {
if (dbConnection != null) {
try {
dbConnection.close();
} catch (Exception ex) {
getLogger().error("Failed to close the DB connection: "+ex.getMessage(), ex);
}
}
}
Check the DatabaseMetaData if you need more/different info.
Example of output:
DB Product Name = Oracle
DB Product Version= Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
DB Driver Name = Oracle JDBC driver
DB Driver Version = 11.2.0.2.0
DB Schema = XXXXX
DB URL = jdbc:oracle:thin:@XXX.XXX.XXX.XXX:11010:MYSID