From: Richard Millet Date: Fri, 14 Dec 2012 20:47:44 +0000 (-0800) Subject: Move method getDatabaseName() which returns the database name for a given tenant... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=4fa969adab2e2e340ea4304062af9ee94efce295;p=tmp%2Fjakarta-migration.git Move method getDatabaseName() which returns the database name for a given tenant bindings repo domain from ConfigUtils to JDBCTools class. --- diff --git a/services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java b/services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java index 4074db550..0d40e4217 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java +++ b/services/common/src/main/java/org/collectionspace/services/common/storage/JDBCTools.java @@ -232,16 +232,17 @@ public class JDBCTools { * * @return the database product name */ - public static String getDatabaseProductName() { + public static String getDatabaseProductName(String dataSourceName, + String repositoryName) { if (DBProductName == null) { Connection conn = null; try { - conn = getConnection(CSPACE_DATASOURCE_NAME, DEFAULT_CSPACE_DATABASE_NAME); + conn = getConnection(dataSourceName, repositoryName); DBProductName = conn.getMetaData().getDatabaseProductName(); } catch (Exception e) { if (logger.isTraceEnabled() == true) { logger.trace(String.format("Could not open a connection. DataSource='%s' DB='%s'.", - CSPACE_DATASOURCE_NAME, DEFAULT_CSPACE_DATABASE_NAME)); + dataSourceName, repositoryName)); } } finally { try { @@ -269,14 +270,13 @@ public class JDBCTools { String repositoryName) throws Exception { DatabaseProductType result = DatabaseProductType.UNRECOGNIZED; - String productName = getDatabaseProductName(); + String productName = getDatabaseProductName(dataSourceName, repositoryName); if (productName.matches("(?i).*mysql.*")) { result = DatabaseProductType.MYSQL; } else if (productName.matches("(?i).*postgresql.*")) { result = DatabaseProductType.POSTGRESQL; } else { - throw new Exception("Unrecognized database system " - + productName); + throw new Exception("Unrecognized database system " + productName); } return result; @@ -297,7 +297,7 @@ public class JDBCTools { } /** - * Returns the catalog name for an open JDBC connection. + * Returns the catalog/database name for an open JDBC connection. * * @param conn an open JDBC Connection * @return the catalog name.