GUACAMOLE-1407: Automatically detect whether MySQL or MariaDB version of "Connector/J" is installed.

This commit is contained in:
Michael Jumper
2021-08-26 17:58:32 -07:00
parent 5cf030a9e3
commit be1ad5dff3
3 changed files with 82 additions and 10 deletions

View File

@@ -192,4 +192,24 @@ public abstract class JDBCEnvironment extends DelegatingEnvironment {
*/
public abstract String getPassword() throws GuacamoleException;
/**
* Returns whether the given Java class is defined within the classpath.
*
* @param classname
* The name of the Java class to check.
*
* @return
* true if the given Java class is present within the classpath, false
* otherwise.
*/
public static boolean isClassDefined(String classname) {
try {
Class.forName(classname, false, JDBCEnvironment.class.getClassLoader());
return true;
}
catch (ClassNotFoundException e) {
return false;
}
}
}