MySQLの場合
public static boolean isJdbcMySQL() { DataContext dataContext = DataContext.getThreadDataContext(); String url = null; try { url = dataContext .getParentDataDomain() .getNode(Database.getDomainName() + "domainNode") .getDataSource() .getConnection() .getMetaData() .getURL(); } catch (SQLException e) { logger.warn(e.getMessage(), e); } return url != null && url.startsWith("jdbc:mysql"); }
PostgreSQLの場合
public static boolean isJdbcPostgreSQL() { DataContext dataContext = DataContext.getThreadDataContext(); String url = null; try { url = dataContext .getParentDataDomain() .getNode(Database.getDomainName() + "domainNode") .getDataSource() .getConnection() .getMetaData() .getURL(); } catch (SQLException e) { logger.warn(e.getMessage(), e); } return url != null && url.startsWith("jdbc:postgresql"); }