Skip to content

Instantly share code, notes, and snippets.

@gtudan
Created August 8, 2017 17:29
Show Gist options
  • Save gtudan/5ec63bc78500ae1bff612dca3e744162 to your computer and use it in GitHub Desktop.
Save gtudan/5ec63bc78500ae1bff612dca3e744162 to your computer and use it in GitHub Desktop.
@Override
public Connection getConnection(String tenantIdentifier) throws SQLException {
log.debugf("Requesting connection for tenant %s", tenantIdentifier);
final Connection connection = getAnyConnection();
connection.createStatement().execute("USE " + tenantIdentifier);
return connection;
}
@Override
public void releaseConnection(String tenantIdentifier, Connection connection) throws SQLException {
final String schema = configurationService.getSetting(
AvailableSettings.DEFAULT_SCHEMA, String.class, "public");
selectConnectionProvider(tenantIdentifier).closeConnection(connection);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment