Skip to content

Commit

Permalink
Merge branch '3.12' of https://github.com/JumpMind/symmetric-ds into …
Browse files Browse the repository at this point in the history
…3.12
  • Loading branch information
JJStarrett committed Jul 1, 2020
2 parents 13fa696 + 0957c9b commit 3acd180
Showing 1 changed file with 27 additions and 3 deletions.
Expand Up @@ -285,11 +285,13 @@ public static String[] determineDatabaseNameVersionSubprotocol(DataSource dataSo
}
}

if(nameVersion[0].equalsIgnoreCase(DatabaseNamesConstants.ORACLE)) {
if (nameVersion[0].equalsIgnoreCase(DatabaseNamesConstants.ORACLE)) {
int majorVersion = Integer.valueOf(metaData.getDatabaseMajorVersion());
int minorVersion = Integer.valueOf(metaData.getDatabaseMinorVersion());
if(majorVersion > 12 || (majorVersion == 12 && minorVersion >= 2)) {
nameVersion[0] = DatabaseNamesConstants.ORACLE122;
if (majorVersion > 12 || (majorVersion == 12 && minorVersion >= 2)) {
if (isOracle122Compatible(connection)) {
nameVersion[0] = DatabaseNamesConstants.ORACLE122;
}
}
}

Expand Down Expand Up @@ -439,6 +441,28 @@ private static int getGreenplumVersion(Connection connection) {
return productVersion;
}

private static boolean isOracle122Compatible(Connection connection) {
boolean isOracle122 = false;
String sql = "select value from v$parameter where name = 'compatible'";
try (Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery(sql)) {
if (rs.next()) {
String value = rs.getString(1);
if (value != null) {
String[] valueArr = value.split("\\.");
if (valueArr != null) {
if ((valueArr.length > 0 && Integer.parseInt(valueArr[0]) > 12) ||
(valueArr.length > 1 && Integer.parseInt(valueArr[0]) == 12 && Integer.parseInt(valueArr[1]) >= 2)) {
isOracle122 = true;
}
}
}
}
} catch (SQLException e) {
log.error("Failed to check Oracle compatible parameter", e);
}
return isOracle122;
}

public static String getDatabaseProductVersion(DataSource dataSource) {
Connection connection = null;

Expand Down

0 comments on commit 3acd180

Please sign in to comment.