mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-919: pass through defaultStatementTimeout
Testing a workaround for handling dropped TCP connections to the Postgres database.
This commit is contained in:
@@ -69,6 +69,7 @@ public class PostgreSQLAuthenticationProviderModule implements Module {
|
|||||||
myBatisProperties.setProperty("JDBC.autoCommit", "false");
|
myBatisProperties.setProperty("JDBC.autoCommit", "false");
|
||||||
myBatisProperties.setProperty("mybatis.pooled.pingEnabled", "true");
|
myBatisProperties.setProperty("mybatis.pooled.pingEnabled", "true");
|
||||||
myBatisProperties.setProperty("mybatis.pooled.pingQuery", "SELECT 1");
|
myBatisProperties.setProperty("mybatis.pooled.pingQuery", "SELECT 1");
|
||||||
|
myBatisProperties.setProperty("mybatis.configuration.defaultStatementTimeout", environment.getPostgreSQLDefaultStatementTimeout());
|
||||||
|
|
||||||
// Use UTF-8 in database
|
// Use UTF-8 in database
|
||||||
driverProperties.setProperty("characterEncoding", "UTF-8");
|
driverProperties.setProperty("characterEncoding", "UTF-8");
|
||||||
|
@@ -48,6 +48,14 @@ public class PostgreSQLEnvironment extends JDBCEnvironment {
|
|||||||
*/
|
*/
|
||||||
private static final int DEFAULT_PORT = 5432;
|
private static final int DEFAULT_PORT = 5432;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default defaultStatementTimeout (in seconds),
|
||||||
|
* if POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT is not specified.
|
||||||
|
* Default to null (no timeout)
|
||||||
|
* https://mybatis.org/mybatis-3/configuration.html
|
||||||
|
*/
|
||||||
|
private static final String DEFAULT_DEFAULT_STATEMENT_TIMEOUT = "null";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether a database user account is required by default for authentication
|
* Whether a database user account is required by default for authentication
|
||||||
* to succeed.
|
* to succeed.
|
||||||
@@ -250,6 +258,23 @@ public class PostgreSQLEnvironment extends JDBCEnvironment {
|
|||||||
return getRequiredProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_PASSWORD);
|
return getRequiredProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_PASSWORD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the defaultStatementTimeout set for PostgreSQL connections.
|
||||||
|
* If unspecified, this will be the default "null" (no timeout)
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* The statement timeout (in seconds)
|
||||||
|
*
|
||||||
|
* @throws GuacamoleException
|
||||||
|
* If an error occurs while retrieving the property value.
|
||||||
|
*/
|
||||||
|
public String getPostgreSQLDefaultStatementTimeout() throws GuacamoleException {
|
||||||
|
return getProperty(
|
||||||
|
PostgreSQLGuacamoleProperties.POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT,
|
||||||
|
DEFAULT_DEFAULT_STATEMENT_TIMEOUT
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRecursiveQuerySupported(SqlSession session) {
|
public boolean isRecursiveQuerySupported(SqlSession session) {
|
||||||
return true; // All versions of PostgreSQL support recursive queries through CTEs
|
return true; // All versions of PostgreSQL support recursive queries through CTEs
|
||||||
|
@@ -94,6 +94,18 @@ public class PostgreSQLGuacamoleProperties {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the number of seconds the driver will wait for
|
||||||
|
* a response from the database.
|
||||||
|
*/
|
||||||
|
public static final StringGuacamoleProperty
|
||||||
|
POSTGRESQL_DEFAULT_STATEMENT_TIMEOUT = new StringGuacamoleProperty(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() { return "postgresql-default-statement-timeout"; }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether a user account within the database is required for authentication
|
* Whether a user account within the database is required for authentication
|
||||||
* to succeed, even if the user has been authenticated via another
|
* to succeed, even if the user has been authenticated via another
|
||||||
|
@@ -354,6 +354,10 @@ END
|
|||||||
"postgresql-default-max-group-connections-per-user" \
|
"postgresql-default-max-group-connections-per-user" \
|
||||||
"$POSTGRES_DEFAULT_MAX_GROUP_CONNECTIONS_PER_USER"
|
"$POSTGRES_DEFAULT_MAX_GROUP_CONNECTIONS_PER_USER"
|
||||||
|
|
||||||
|
set_optional_property \
|
||||||
|
"postgresql-default-statement-timeout" \
|
||||||
|
"$POSTGRES_DEFAULT_STATEMENT_TIMEOUT"
|
||||||
|
|
||||||
set_optional_property \
|
set_optional_property \
|
||||||
"postgresql-user-required" \
|
"postgresql-user-required" \
|
||||||
"$POSTGRES_USER_REQUIRED"
|
"$POSTGRES_USER_REQUIRED"
|
||||||
|
Reference in New Issue
Block a user