List of usage examples for java.sql ResultSet getLong
long getLong(String columnLabel) throws SQLException;
ResultSet
object as a long
in the Java programming language. From source file:uta.ak.usttmp.common.dao.mapper.EvolutionRelaRowMapper.java
@Override public Object mapRow(ResultSet rs, int rowNum) throws SQLException { EvolutionRelationship er = new EvolutionRelationship(); String queryTp = "select * from c_topic where mme_eid=?"; Topic preTopic = (Topic) this.jdbcTemplate.queryForObject(queryTp, new TopicRowMapper(), rs.getLong("pre_topic_id")); Topic nextTopic = (Topic) this.jdbcTemplate.queryForObject(queryTp, new TopicRowMapper(), rs.getLong("next_topic_id")); er.setNextTopic(nextTopic);// w w w . j a va 2 s .co m er.setPreTopic(preTopic); er.setRankAgainstNextTopicInPreGroup(rs.getInt("rank_against_next_topic_in_pre_group")); er.setRankAgainstPreTopicInNextGroup(rs.getInt("rank_against_pre_topic_in_next_group")); er.setSimilarity(rs.getDouble("similarity")); er.setMiningTaskId(rs.getLong("miningtask_id")); er.setPreTopicSeq(rs.getInt("pre_topic_seq")); er.setNextTopicSeq(rs.getInt("next_topic_seq")); return er; }
From source file:eionet.cr.dao.virtuoso.VirtuosoDeliveryFilterDAO.java
/** * {@inheritDoc}/*from w w w .j a va 2 s. c o m*/ */ @Override public List<DeliveryFilterDTO> getDeliveryFilters(String username) throws DAOException { List<Object> params = new ArrayList<Object>(); params.add(username); StringBuffer selectSql = new StringBuffer(); selectSql.append("SELECT * "); selectSql.append("FROM delivery_filter "); selectSql.append("WHERE username = ? "); selectSql.append("ORDER BY delivery_filter_id DESC"); List<DeliveryFilterDTO> result = executeSQL(selectSql.toString(), params, new SQLResultSetBaseReader<DeliveryFilterDTO>() { @Override public void readRow(ResultSet rs) throws SQLException, ResultSetReaderException { DeliveryFilterDTO dto = new DeliveryFilterDTO(); dto.setId(rs.getLong("delivery_filter_id")); dto.setLocality(rs.getString("locality")); dto.setLocalityLabel(rs.getString("locality_label")); dto.setObligation(rs.getString("obligation")); dto.setObligationLabel(rs.getString("obligation_label")); dto.setUsername(rs.getString("username")); dto.setYear(rs.getString("year")); resultList.add(dto); } }); return result; }
From source file:eionet.cr.dao.virtuoso.VirtuosoDeliveryFilterDAO.java
/** * {@inheritDoc}//from w w w . j av a 2 s .com */ @Override public DeliveryFilterDTO getDeliveryFilte(long id) throws DAOException { List<Object> params = new ArrayList<Object>(); params.add(id); StringBuffer selectSql = new StringBuffer(); selectSql.append("SELECT * "); selectSql.append("FROM delivery_filter "); selectSql.append("WHERE delivery_filter_id = ? "); DeliveryFilterDTO result = executeUniqueResultSQL(selectSql.toString(), params, new SQLResultSetBaseReader<DeliveryFilterDTO>() { @Override public void readRow(ResultSet rs) throws SQLException, ResultSetReaderException { DeliveryFilterDTO dto = new DeliveryFilterDTO(); dto.setId(rs.getLong("delivery_filter_id")); dto.setLocality(rs.getString("locality")); dto.setLocalityLabel(rs.getString("locality_label")); dto.setObligation(rs.getString("obligation")); dto.setObligationLabel(rs.getString("obligation_label")); dto.setUsername(rs.getString("username")); dto.setYear(rs.getString("year")); resultList.add(dto); } }); return result; }
From source file:com.grayfox.server.dao.jdbc.RecommendationJdbcDao.java
@Override public List<Recommendation> findNearestWithHighRating(Location location, Integer radius, Locale locale) { List<Recommendation> recommendations = getJdbcTemplate().query(getQuery("Poi.findNearestWithHighRating"), (ResultSet rs, int i) -> { Recommendation recommendation = new Recommendation(); Poi poi = new Poi(); int columnIndex = 1; poi.setId(rs.getLong(columnIndex++)); poi.setName(rs.getString(columnIndex++)); poi.setLocation(new Location()); poi.getLocation().setLatitude(rs.getDouble(columnIndex++)); poi.getLocation().setLongitude(rs.getDouble(columnIndex++)); poi.setFoursquareId(rs.getString(columnIndex++)); poi.setFoursquareRating(rs.getDouble(columnIndex++)); recommendation.setType(Recommendation.Type.GLOBAL); recommendation.setReason(Messages.get("recommendation.global.reason", locale)); recommendation.setPoi(poi); return recommendation; }, location.getLatitude(), location.getLongitude(), radius); recommendations.forEach(recommendation -> recommendation.getPoi().setCategories(new HashSet<>( categoryDao.findByPoiFoursquareId(recommendation.getPoi().getFoursquareId(), locale)))); return recommendations; }
From source file:org.psystems.dicom.browser.server.stat.StatClientRequestsChartServlet.java
/** * @param connection// ww w . j a v a 2s . c o m * @param series * @param metrica * @param timeBegin * @param timeEnd * @param dataset * @throws SQLException */ private void getMetrics(Connection connection, String series, String metrica, long timeBegin, long timeEnd, DefaultCategoryDataset dataset) throws SQLException { PreparedStatement stmt = null; try { // String dateStr = format.format(calendar.getTime()); // System.out.println("!!! " + dateStr); SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy"); stmt = connection.prepareStatement("SELECT METRIC_VALUE_LONG, METRIC_DATE" + " FROM WEBDICOM.DAYSTAT WHERE METRIC_NAME = ? and " + " METRIC_DATE BETWEEN ? AND ? "); stmt.setString(1, metrica); stmt.setDate(2, new java.sql.Date(timeBegin)); stmt.setDate(3, new java.sql.Date(timeEnd)); ResultSet rs = stmt.executeQuery(); while (rs.next()) { long value = rs.getLong("METRIC_VALUE_LONG"); Date date = rs.getDate("METRIC_DATE"); String dateStr = format.format(date.getTime()); String category = dateStr; dataset.addValue(value, series, category); // System.out.println("!!!! " + metrica + "=" + dateStr + "=" // + value); } rs.close(); } finally { if (stmt != null) stmt.close(); } }
From source file:eu.databata.engine.dao.PropagationSqlLogRowMapper.java
@Override public PropagationSqlLog mapRow(ResultSet rs, int rowNum) throws SQLException { PropagationSqlLog history = new PropagationSqlLog(); history.setModuleName(rs.getString("module_name")); history.setDbChangeCode(rs.getString("db_change_code")); history.setSqlText(rs.getString("sql_text")); history.setRowsUpdated(rs.getLong("rows_updated")); history.setErrorCode(rs.getInt("error_code")); history.setErrorText(rs.getString("error_text")); history.setUpdateTime(rs.getTimestamp("update_time")); history.setExecutionTime(rs.getBigDecimal("execution_time")); return history; }
From source file:com.googlecode.starflow.engine.repository.impl.ProcessDefineRepositoryImpl.java
public List<ProcessDefine> findProcessDefines(String processDefName) { return this.getJdbcTemplate().query(findProcessDefinesSQL, new RowMapper<ProcessDefine>() { @Override/* w w w. j a v a 2 s. c o m*/ public ProcessDefine mapRow(ResultSet resultSet, int index) throws SQLException { ProcessDefine processDefine = new ProcessDefine(); processDefine.setProcessDefId(resultSet.getLong("processDefId")); processDefine.setProcessDefName(resultSet.getString("processDefName")); processDefine.setProcessCHName(resultSet.getString("processCHName")); processDefine.setCurrentState(resultSet.getInt("currentState")); processDefine.setVersionSign(resultSet.getString("versionSign")); return processDefine; } }, processDefName); }
From source file:com.grayfox.server.dao.jdbc.UserJdbcDao.java
@Override public List<Category> findLikesByFoursquareId(String foursquareId, Locale locale) { return getJdbcTemplate().query(getQuery("User.findLikesByUserFoursquareId", locale), (ResultSet rs, int i) -> { Category category = new Category(); int columnIndex = 1; category.setId(rs.getLong(columnIndex++)); category.setName(rs.getString(columnIndex++)); category.setIconUrl(rs.getString(columnIndex++)); category.setFoursquareId(rs.getString(columnIndex++)); return category; }, foursquareId);/*from w w w .j av a 2s.c o m*/ }
From source file:com.mtgi.analytics.JdbcBehaviorEventPersisterImpl.java
protected synchronized Long nextId(Connection conn, PreparedStatement[] ptr) throws SQLException { if (currentId == nextId) { if (ptr[0] == null) ptr[0] = conn.prepareStatement(idSql); ResultSet rs = ptr[0].executeQuery(); try {/* w ww. j a va2 s.c om*/ rs.next(); currentId = rs.getLong(1); nextId = currentId + idIncrement; } finally { closeResultSet(rs); } } return currentId++; }
From source file:com.mvdb.etl.dao.impl.JdbcOrderDAO.java
@Override public void findAll(Timestamp modifiedAfter, final Consumer consumer) { String sql = "SELECT * FROM ORDERS where orders.update_time >= ?"; getJdbcTemplate().query(sql, new Object[] { modifiedAfter }, new RowCallbackHandler() { @Override/* ww w .j av a 2s . co m*/ public void processRow(ResultSet row) throws SQLException { Order order = new Order(); order.setOrderId(row.getLong("order_id")); order.setNote(row.getString("note")); order.setSaleCode(row.getInt("sale_code")); Date createTime = new java.util.Date(row.getTimestamp("create_time").getTime()); order.setCreateTime(createTime); Date updateTime = new java.util.Date(row.getTimestamp("update_time").getTime()); order.setUpdateTime(updateTime); consumer.consume(order); } }); }