List of usage examples for java.sql ResultSet getTimestamp
java.sql.Timestamp getTimestamp(String columnLabel) throws SQLException;
ResultSet
object as a java.sql.Timestamp
object in the Java programming language. From source file:org.spring.data.gemfire.app.dao.provider.JdbcUserDao.java
protected User mapUser(final ResultSet resultSet, final int rowIndex) throws SQLException { User user = new User(resultSet.getString("username")); user.setEmail(resultSet.getString("email")); user.setActive(Boolean.valueOf(resultSet.getString("active"))); user.setSince(convert(resultSet.getTimestamp("since"))); return user;//from ww w . j a va 2 s. co m }
From source file:com.ex.Dao.impl.GroupDaoImpl.java
@Override public Group findGroupById(String id) { String sql = "SELECT * FROM " + dbName + " WHERE GROUP_ID = '" + id + "'"; return jdbcTemplate.query(sql, new ResultSetExtractor<Group>() { @Override//ww w . ja v a 2s. c o m public Group extractData(ResultSet rs) throws SQLException, DataAccessException { if (rs.next()) { Group group = new Group(); group.setId(rs.getString("group_id")); group.setVersion(rs.getLong("version")); group.setXml(rs.getString("xml")); group.setGroupName(rs.getString("group_name")); group.setCreatedBy(rs.getString("created_by")); group.setUpdatedAt(rs.getTimestamp("updated_at")); return group; } return null; } }); }
From source file:com.ex.Dao.impl.GroupDaoImpl.java
@Override public Group findGroupByName(String name) { String sql = "SELECT * FROM " + dbName + " WHERE GROUP_NAME = '" + name + "'"; return jdbcTemplate.query(sql, new ResultSetExtractor<Group>() { @Override/* w w w . j av a2s . com*/ public Group extractData(ResultSet rs) throws SQLException, DataAccessException { if (rs.next()) { Group group = new Group(); group.setId(rs.getString("group_id")); group.setVersion(rs.getLong("version")); group.setXml(rs.getString("xml")); group.setGroupName(rs.getString("group_name")); group.setCreatedBy(rs.getString("created_by")); group.setUpdatedAt(rs.getTimestamp("updated_at")); return group; } return null; } }); }
From source file:nl.ordina.bag.etl.dao.AbstractBAGMutatiesDAO.java
@Override public List<BAGMutatie> getNextBAGMutaties() { try {/*from w ww. j a va 2 s . co m*/ List<BAGMutatie> result = jdbcTemplate .query("select id, tijdstip_verwerking, volgnr_verwerking, object_type, mutatie_product" + " from bag_mutatie" + " where tijdstip_verwerking = (select min(tijdstip_verwerking) from bag_mutatie)" + " order by volgnr_verwerking asc", new RowMapper<BAGMutatie>() { @Override public BAGMutatie mapRow(ResultSet rs, int row) throws SQLException { try { BAGMutatie result = new BAGMutatie(); result.setId(rs.getLong("id")); result.setTijdstipVerwerking(Utils .toXMLGregorianCalendar(rs.getTimestamp("tijdstip_verwerking"))); result.setVolgnrVerwerking(rs.getInt("volgnr_verwerking")); result.setObjectType(BAGObjectType.values()[rs.getInt("object_type")]); result.setMutatieProduct(XMLMessageBuilder.getInstance(MutatieProduct.class) .handle(rs.getCharacterStream("mutatie_product"), MutatieProduct.class)); return result; } catch (JAXBException e) { throw new DAOException(e); } } }); return result; } catch (DataAccessException e) { throw new DAOException(e); } }
From source file:edu.umass.cs.gnsclient.client.util.SimpleKeyStore.java
public Date readTime(String key) { ResultSet rs = null; try {//from w w w .j av a 2s. c om PreparedStatement getStatement = conn .prepareStatement("select READTIME from " + TABLE_NAME + " where KEYFIELD=?"); getStatement.setString(1, key); rs = getStatement.executeQuery(); if (rs.next()) { return rs.getTimestamp("READTIME"); } } catch (SQLException e) { DerbyControl.printSQLException(e); } finally { safelyClose(rs); } return null; }
From source file:com.concursive.connect.web.modules.discussion.dao.ForumIndexer.java
/** * Given a database and a Lucene writer, this method will add content to the * searchable index/*from w w w .j a va 2 s . c om*/ * * @param writer Description of the Parameter * @param db Description of the Parameter * @param context * @throws SQLException Description of the Exception * @throws IOException Description of the Exception */ public void add(IIndexerService writer, Connection db, IndexerContext context) throws SQLException, IOException { int count = 0; PreparedStatement pst = db .prepareStatement("SELECT category_id, project_id, subject, description, modified " + "FROM project_issues_categories " + "WHERE project_id > -1 "); ResultSet rs = pst.executeQuery(); while (rs.next() && context.getEnabled()) { ++count; // read the record Forum forum = new Forum(); forum.setId(rs.getInt("category_id")); forum.setProjectId(rs.getInt("project_id")); forum.setSubject(rs.getString("subject")); forum.setDescription(rs.getString("description")); forum.setModified(rs.getTimestamp("modified")); // add the document writer.indexAddItem(forum, false); } rs.close(); pst.close(); LOG.info("IssueCategoryIndexer-> Finished: " + count); }
From source file:edu.umass.cs.gnsclient.client.util.SimpleKeyStore.java
public Date updateTime(String key) { ResultSet rs = null; try {/*from www . j av a 2s .c o m*/ PreparedStatement getStatement = conn .prepareStatement("select UPDATETIME from " + TABLE_NAME + " where KEYFIELD=?"); getStatement.setString(1, key); rs = getStatement.executeQuery(); if (rs.next()) { return rs.getTimestamp("UPDATETIME"); } } catch (SQLException e) { DerbyControl.printSQLException(e); } finally { safelyClose(rs); } return null; }
From source file:com.taobao.itest.listener.ITestDataSetListener.java
private Date getDbCurrentTime(Connection connection, String dbType) throws SQLException { Date currentTime = null;/*from w w w . j av a 2 s .c o m*/ String sql = null; if ("MySQL".equalsIgnoreCase(dbType)) { sql = "SELECT now()"; } else if ("Oracle".equalsIgnoreCase(dbType)) { sql = "SELECT sysdate FROM dual"; } if (sql != null) { ResultSet rs = connection.createStatement().executeQuery(sql); while (rs.next()) { currentTime = rs.getTimestamp(1); } } else { currentTime = new Date(); } return currentTime; }
From source file:edu.umass.cs.gnsclient.client.util.keystorage.SimpleKeyStore.java
/** * * @param key/*ww w .jav a 2s . com*/ * @return the read time as a DATE */ public Date readTime(String key) { ResultSet rs = null; try { PreparedStatement getStatement = conn .prepareStatement("select READTIME from " + TABLE_NAME + " where KEYFIELD=?"); getStatement.setString(1, key); rs = getStatement.executeQuery(); if (rs.next()) { return rs.getTimestamp("READTIME"); } } catch (SQLException e) { DerbyControl.printSQLException(e); } finally { safelyClose(rs); } return null; }
From source file:ru.org.linux.topic.LastMiniNewsDao.java
public List<LastMiniNews> getTopics(final int perPage) { String sql = "select topics.id as msgid, groups.urlname, groups.section, topics.title, lastmod, topics.stat1 as c " + "from topics " + "join groups on groups.id = topics.groupid" + " where " + " topics.postdate>(CURRENT_TIMESTAMP-'1 month 1 day'::interval) and " + // ? ?? " not deleted and " + // ? " groups.section = 1 and topics.moderate and commitdate is not null and not draft " + // ?? " and minor order by topics.commitdate desc limit 10"; // 10 return jdbcTemplate.query(sql, new RowMapper<LastMiniNews>() { @Override//w w w. jav a 2 s. c o m public LastMiniNews mapRow(ResultSet rs, int i) throws SQLException { final int answers = rs.getInt("c"); final int answers0 = (answers == 0) ? 1 : answers; final int tmp = answers0 / perPage; final int pages = (answers0 % perPage > 0) ? tmp + 1 : tmp; LastMiniNews result = new LastMiniNews( sectionService.getSection(rs.getInt("section")).getSectionLink() + rs.getString("urlname") + '/' + rs.getInt("msgid"), rs.getTimestamp("lastmod"), rs.getString("title"), answers, pages); return result; } }); }