Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
@Component(service=UkelonnService.class, immediate=true)
public class UkelonnServiceProvider extends UkelonnServiceBase {
public Account getAccount(String username) {
try(Connection connection = database.getConnection()) {
try(PreparedStatement statement = connection.prepareStatement("select * from accounts_view where username=?")) {
statement.setString(1, username);
try(ResultSet resultset = statement.executeQuery()) {
if (
return mapAccount(resultset);
throw new UkelonnException(String.format("Got an empty ResultSet while fetching account from the database for user \\\"%s\\\"", username));
} catch (SQLException e) {
throw new UkelonnException(String.format("Caught SQLException while fetching account from the database for user \"%s\"", username), e);
public Account mapAccount(ResultSet results) throws SQLException {
String username = results.getString(UkelonnServiceProvider.USERNAME);
no.priv.bang.osgiservice.users.User user = useradmin.getUser(username);
return new Account(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.