public int getUserId(String username) throws UserStoreException {
String sqlStmt = realmConfig
.getUserStoreProperty(JDBCRealmConstants.GET_USERID_FROM_USERNAME);
if (sqlStmt == null) {
throw new UserStoreException("The sql statement for retrieving ID is null");
}
int id = -1;
Connection dbConnection = null;
try {
dbConnection = getDBConnection();
if (sqlStmt.contains(UserCoreConstants.UM_TENANT_COLUMN)) {
id = DatabaseUtil.getIntegerValueFromDatabase(dbConnection, sqlStmt, username, tenantId);
} else {
id = DatabaseUtil.getIntegerValueFromDatabase(dbConnection, sqlStmt, username);
}
} catch (SQLException e) {
log.error(e.getMessage(), e);
throw new UserStoreException(e.getMessage(), e);
} finally {
DatabaseUtil.closeAllConnections(dbConnection);
}
return id;
}