mike-jumper commented on a change in pull request #642:
URL: https://github.com/apache/guacamole-client/pull/642#discussion_r697084019
##########
File path:
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/conf/MySQLEnvironment.java
##########
@@ -189,10 +192,30 @@ public PasswordPolicy getPasswordPolicy() {
* If guacamole.properties cannot be parsed.
*/
public MySQLDriver getMySQLDriver() throws GuacamoleException {
- return getProperty(
- MySQLGuacamoleProperties.MYSQL_DRIVER,
- DEFAULT_DRIVER
- );
+
+ // Use any explicitly-specified driver
+ MySQLDriver driver =
getProperty(MySQLGuacamoleProperties.MYSQL_DRIVER);
+ if (driver != null)
+ return driver;
+
+ // Attempt autodetection based on presence of JDBC driver within
+ // classpath...
+
+ if (MySQLDriver.MARIADB.isInstalled()) {
+ logger.info("Installed JDBC driver for MySQL/MariaDB detected as
\"MariaDB Connector/J\".");
+ return MySQLDriver.MARIADB;
+ }
+
+ if (MySQLDriver.MYSQL.isInstalled()) {
+ logger.info("Installed JDBC driver for MySQL/MariaDB detected as
\"MySQL Connector/J\".");
+ return MySQLDriver.MYSQL;
+ }
+
+ // Fallback to MySQL Connector/J if nothing can be found
+ logger.warn("JDBC driver for MySQL/MariaDB couuld not be detected "
+ + "and might not be installed. Assuming MySQL Connector/J...");
+ return FALLBACK_DEFAULT_DRIVER;
Review comment:
Yeah - if neither of the previous attempts succeed, then there really
isn't anything else to try. It would make more sense to throw an exception here
and bail out.
I'll add that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]