try {
final String username = credential.getUsername();
final String password = getPasswordEncoder().encode(credential.getPassword());
final Connection c = this.getDataSource().getConnection(username, password);
DataSourceUtils.releaseConnection(c, this.getDataSource());
return createHandlerResult(credential, new SimplePrincipal(username), null);
} catch (final SQLException e) {
throw new FailedLoginException(e.getMessage());
} catch (final Exception e) {
throw new PreventedException("Unexpected SQL connection error", e);
}