List of usage examples for org.springframework.jdbc.support.rowset SqlRowSet next
boolean next() throws InvalidResultSetAccessException;
From source file:ru.org.linux.poll.PollDao.java
/** * ? ./* w ww.j a v a 2s .co m*/ * * @param pollId ?? * @return ? * @throws PollNotFoundException ? ? ?? */ public Poll getPoll(final int pollId) throws PollNotFoundException { int currentPollId = getCurrentPollId(); SqlRowSet rs = jdbcTemplate.queryForRowSet(queryPool, pollId); if (!rs.next()) { throw new PollNotFoundException(); } return new Poll(pollId, rs.getInt("topic"), rs.getBoolean("multiselect"), pollId == currentPollId, getVoteDTO(pollId)); }
From source file:ru.org.linux.spring.SameIPController.java
@RequestMapping("/sameip.jsp") public ModelAndView sameIP(HttpServletRequest request, @RequestParam(required = false) Integer msgid) throws Exception { Template tmpl = Template.getTemplate(request); if (!tmpl.isModeratorSession()) { throw new AccessViolationException("Not moderator"); }/*from w w w . j av a 2s . co m*/ String ip; ModelAndView mv = new ModelAndView("sameip"); int userAgentId = 0; if (msgid != null) { SqlRowSet rs = jdbcTemplate.queryForRowSet("SELECT postip, ua_id FROM topics WHERE id=?", msgid); if (!rs.next()) { rs = jdbcTemplate.queryForRowSet("SELECT postip, ua_id FROM comments WHERE id=?", msgid); if (!rs.next()) { throw new MessageNotFoundException(msgid); } } ip = rs.getString("postip"); userAgentId = rs.getInt("ua_id"); if (ip == null) { throw new ScriptErrorException("No IP data for #" + msgid); } } else { ip = ServletParameterParser.getIP(request, "ip"); } mv.getModel().put("ip", ip); mv.getModel().put("uaId", userAgentId); mv.getModel().put("topics", getTopics(ip)); mv.getModel().put("comments", getComments(ip)); mv.getModel().put("users", getUsers(ip, userAgentId)); IPBlockInfo blockInfo = ipBlockDao.getBlockInfo(ip); Boolean allowPosting = false; Boolean captchaRequired = true; if (blockInfo.isInitialized()) { mv.getModel().put("blockInfo", blockInfo); allowPosting = blockInfo.isAllowRegistredPosting(); captchaRequired = blockInfo.isCaptchaRequired(); mv.getModel().put("blockModerator", userDao.getUserCached(blockInfo.getModerator())); } mv.addObject("allowPosting", allowPosting); mv.addObject("captchaRequired", captchaRequired); mv.getModel().put("tor", IPBlockDao.getTor(ip)); return mv; }
From source file:org.apereo.lap.services.ThresholdTriggerService.java
public boolean triggerSSP(List<Output> outputs) { List<Configuration> configurations = configurationRepository.findAll(); // Check If Configuration Is Available And Active For SSP if (configurations.size() == 0 || !configurations.get(0).isSSPActive()) return false; for (Output output : outputs) { Map<String, String> sourceToHeaderMap = output.makeSourceTargetMap(); String selectSQL = output.makeTempDBSelectSQL(); SqlRowSet rowSet; try {/*from ww w .j a v a2 s .c o m*/ rowSet = storage.getTempJdbcTemplate().queryForRowSet(selectSQL); } catch (Exception e) { throw new RuntimeException("Failure while trying to retrieve the output data set: " + selectSQL); } while (rowSet.next()) { if (!rowSet.wasNull()) { String[] rowVals = new String[sourceToHeaderMap.size()]; if (rowVals.length > 0) { String userId = rowSet.getString(1); if (rowVals.length > 2) { try { if (rowSet.getString(3) == "HIGH RISK") { try { sspService.createEarlyAlert(configurations.get(0).getSspBaseUrl(), userId); } catch (IOException ex) { logger.error(ex.getMessage()); } } } catch (NumberFormatException ex) { logger.error(ex.getMessage()); } } } } } return true; } return false; }
From source file:com.emc.ecs.sync.service.SqliteDbServiceTest.java
private SqlRowSet getRowSet(String id) { JdbcTemplate jdbcTemplate = dbService.getJdbcTemplate(); SqlRowSet rowSet = jdbcTemplate .queryForRowSet("SELECT * FROM " + dbService.getObjectsTableName() + " WHERE source_id=?", id); rowSet.next(); return rowSet; }
From source file:org.apereo.lap.services.output.StorageOutputHandler.java
@Override public OutputResult writeOutput(Output output) { OutputResult result = new OutputResult(output); Map<String, String> sourceToHeaderMap = output.makeSourceTargetMap(); String selectSQL = output.makeTempDBSelectSQL(); SqlRowSet rowSet; try {/*w ww.j a v a2 s . c o m*/ rowSet = storage.getTempJdbcTemplate().queryForRowSet(selectSQL); } catch (Exception e) { throw new RuntimeException("Failure while trying to retrieve the output data set: " + selectSQL); } String groupId = UUID.randomUUID().toString(); while (rowSet.next()) { RiskConfidence riskConfidence = new RiskConfidence(); if (!rowSet.wasNull()) { riskConfidence.setGroupId(groupId); String[] rowVals = new String[sourceToHeaderMap.size()]; if (rowVals.length > 0) riskConfidence.setAlternativeId(rowSet.getString(1)); if (rowVals.length > 1) riskConfidence.setCourseId(rowSet.getString(2)); if (rowVals.length > 2) riskConfidence.setModelRiskConfidence(rowSet.getString(3)); riskConfidenceRepository.save(riskConfidence); } } return result; }
From source file:test.Test_User.java
public void xx() { String name = "GoW"; String sql = "select password, id from fc_user " + " where name_login = " + DaoTemplate.quote(name); SqlRowSet rowSet = userDao.getJdbcTemplate().queryForRowSet(sql); System.out.println((rowSet.isLast())); if (rowSet.next()) { System.out.println((rowSet.isLast())); System.out.println(sql + "\n"); String result = rowSet.getString("id"); System.err.println(result); }/*from w w w. j a v a 2 s .c o m*/ }
From source file:ru.org.linux.tracker.TrackerDao.java
public List<TrackerItem> getTrackAll(TrackerFilterEnum filter, User currentUser, Timestamp interval, int topics, int offset, final int messagesInPage) { MapSqlParameterSource parameter = new MapSqlParameterSource(); parameter.addValue("interval", interval); parameter.addValue("topics", topics); parameter.addValue("offset", offset); String partIgnored;//from ww w. ja v a2 s .c o m if (currentUser != null) { partIgnored = queryPartIgnored + queryPartTagIgnored; parameter.addValue("userid", currentUser.getId()); } else { partIgnored = ""; } String partFilter; String partWiki = queryPartWiki; switch (filter) { case ALL: partFilter = ""; break; case NOTALKS: partFilter = queryPartNoTalks; break; case TECH: partFilter = queryPartTech; break; case MINE: if (currentUser != null) { partFilter = queryPartMine; partWiki = queryPartWikiMine; } else { partFilter = ""; } break; default: partFilter = ""; } boolean showUncommited = currentUser != null && (currentUser.isModerator() || currentUser.isCorrector()); String partUncommited = showUncommited ? "" : noUncommited; String query; if (filter != TrackerFilterEnum.ZERO) { query = String.format(queryTrackerMain, partUncommited, partIgnored, partFilter, partUncommited, partIgnored, partFilter, partWiki); } else { query = String.format(queryTrackerZeroMain, partIgnored); } SqlRowSet resultSet = jdbcTemplate.queryForRowSet(query, parameter); List<TrackerItem> res = new ArrayList<>(topics); while (resultSet.next()) { User author; try { int author_id = resultSet.getInt("author"); if (author_id != 0) { author = userDao.getUserCached(author_id); } else { author = null; } } catch (UserNotFoundException e) { throw new RuntimeException(e); } int msgid = resultSet.getInt("id"); Timestamp lastmod = resultSet.getTimestamp("lastmod"); int stat1 = resultSet.getInt("stat1"); int groupId = resultSet.getInt("gid"); String groupTitle = resultSet.getString("gtitle"); String title = resultSet.getString("title"); int cid = resultSet.getInt("cid"); User lastCommentBy; try { int id = resultSet.getInt("last_comment_by"); if (id != 0) { lastCommentBy = userDao.getUserCached(id); } else { lastCommentBy = null; } } catch (UserNotFoundException e) { throw new RuntimeException(e); } boolean resolved = resultSet.getBoolean("resolved"); int section = resultSet.getInt("section"); String groupUrlName = resultSet.getString("urlname"); Timestamp postdate = resultSet.getTimestamp("postdate"); boolean uncommited = resultSet.getBoolean("smod") && !resultSet.getBoolean("moderate"); int pages = Topic.getPageCount(stat1, messagesInPage); ImmutableList<String> tags; if (msgid != 0) { tags = topicTagService.getMessageTagsForTitle(msgid); } else { tags = ImmutableList.of(); } res.add(new TrackerItem(author, msgid, lastmod, stat1, groupId, groupTitle, title, cid, lastCommentBy, resolved, section, groupUrlName, postdate, uncommited, pages, tags)); } return res; }
From source file:ru.org.linux.group.GroupController.java
private List<TopicsListItem> prepareTopic(SqlRowSet rs, int messagesInPage) { List<TopicsListItem> topicsList = new ArrayList<>(); while (rs.next()) { User author;/*from w ww .j a v a 2s. c o m*/ try { author = userDao.getUserCached(rs.getInt("userid")); } catch (UserNotFoundException e) { throw new RuntimeException(e); } ImmutableList<String> tags = topicTagService.getMessageTagsForTitle(rs.getInt("msgid")); TopicsListItem topic = new TopicsListItem(author, rs, messagesInPage, tags); topicsList.add(topic); } return topicsList; }
From source file:com.univocity.app.data.Data.java
public void reloadData() { data.clear();//from w w w . j a v a 2 s . com SqlRowSet queryResult = database.getJdbcTemplate().queryForRowSet(selectScript); SqlRowSetMetaData metaData = queryResult.getMetaData(); columnNames = metaData.getColumnNames(); for (int i = 0; i < columnNames.length; i++) { String label = metaData.getColumnLabel(i + 1); if (label != null) { columnNames[i] = label; } } while (queryResult.next()) { Object[] row = new Object[columnNames.length]; for (int i = 0; i < row.length; i++) { row[i] = queryResult.getObject(i + 1); } data.add(row); } }