GUACAMOLE-363: Allow use of alternate JTDS driver.

This commit is contained in:
Nick Couchman
2017-08-29 21:41:00 -04:00
parent 2eb48895bf
commit d6d7c3768f
3 changed files with 42 additions and 2 deletions

View File

@@ -41,6 +41,11 @@ public class SQLServerAuthenticationProviderModule implements Module {
*/ */
private final Properties driverProperties = new Properties(); private final Properties driverProperties = new Properties();
/**
* Whether or not to use JTDS Driver
*/
private Boolean useJTDSDriver = false;
/** /**
* Creates a new SQLServer authentication provider module that configures * Creates a new SQLServer authentication provider module that configures
* driver and MyBatis properties using the given environment. * driver and MyBatis properties using the given environment.
@@ -70,12 +75,18 @@ public class SQLServerAuthenticationProviderModule implements Module {
// Use UTF-8 in database // Use UTF-8 in database
driverProperties.setProperty("characterEncoding", "UTF-8"); driverProperties.setProperty("characterEncoding", "UTF-8");
// Capture whether or not to use the JTDS driver.
this.useJTDSDriver = environment.getSQLServerJTDSDriver();
} }
@Override @Override
public void configure(Binder binder) { public void configure(Binder binder) {
// Bind SQLServer-specific properties // Bind SQLServer-specific properties
if (this.useJTDSDriver)
JdbcHelper.SQL_Server_jTDS.configure(binder);
else
JdbcHelper.SQL_Server_2005_MS_Driver.configure(binder); JdbcHelper.SQL_Server_2005_MS_Driver.configure(binder);
// Bind MyBatis properties // Bind MyBatis properties

View File

@@ -303,4 +303,22 @@ public class SQLServerEnvironment extends JDBCEnvironment {
return getRequiredProperty(SQLServerGuacamoleProperties.SQLSERVER_PASSWORD); return getRequiredProperty(SQLServerGuacamoleProperties.SQLSERVER_PASSWORD);
} }
/**
* Returns whether or not to use the SourceForge JTDS driver for more
* generic JTDS connections instead of the Microsoft-provided JDBC driver.
*
* @return
* True if the JTDS driver should be used; false by default.
*
* @throws GuacamoleException
* If an error occurs while retrieving the property value, or if the
* value was not set, as this property is required.
*/
public Boolean getSQLServerJTDSDriver() throws GuacamoleException {
return getProperty(
SQLServerGuacamoleProperties.SQLSERVER_JTDS_DRIVER,
false
);
}
} }

View File

@@ -197,4 +197,15 @@ public class SQLServerGuacamoleProperties {
}; };
/**
* Whether or not to use the JTDS driver for SQL Server connections.
*/
public static final BooleanGuacamoleProperty
SQLSERVER_JTDS_DRIVER = new BooleanGuacamoleProperty() {
@Override
public String getName() { return "sqlserver-use-jtds-driver"; }
};
} }